celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1528385 - in /incubator/celix/trunk: ./ cmake/cmock/ cmake/cmock/config/ cmake/cmock/lib/ cmake/cmock/src/ cmake/cpputest/include/CppUTest/ cmake/cpputest/include/CppUTestExt/ cmake/cpputest/include/Platforms/Gcc/ cmake/cpputest/include/Pl...
Date Wed, 02 Oct 2013 09:05:32 GMT
Author: abroekhuis
Date: Wed Oct  2 09:05:31 2013
New Revision: 1528385

URL: http://svn.apache.org/r1528385
Log:
CELIX-55: Added tests, removed old unused files (test frameworks etc).

Added:
    incubator/celix/trunk/framework/private/include/version_private.h
    incubator/celix/trunk/framework/private/include/version_range_private.h
    incubator/celix/trunk/framework/private/test/version_range_test.cpp
    incubator/celix/trunk/framework/private/test/version_test.cpp
    incubator/celix/trunk/utils/private/test/array_list_test.cpp
Removed:
    incubator/celix/trunk/cmake/cmock/config/production_environment.rb
    incubator/celix/trunk/cmake/cmock/config/test_environment.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_config.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_file_writer.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_generator.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_generator_plugin_array.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_generator_plugin_callback.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_generator_plugin_cexception.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_generator_plugin_expect.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_generator_plugin_ignore.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_generator_utils.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_header_parser.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_plugin_manager.rb
    incubator/celix/trunk/cmake/cmock/lib/cmock_unityhelper_parser.rb
    incubator/celix/trunk/cmake/cmock/lib/test.h
    incubator/celix/trunk/cmake/cmock/src/cmock.c
    incubator/celix/trunk/cmake/cmock/src/cmock.h
    incubator/celix/trunk/cmake/cmock/test.yml
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineArguments.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineTestRunner.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/JUnitTestOutput.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakAllocator.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetector.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakWarningPlugin.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/PlatformSpecificFunctions.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/SimpleString.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestFailure.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness_c.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestOutput.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestPlugin.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestRegistry.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestResult.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestTestingFixture.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/Utest.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/UtestMacros.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTest/VirtualCall.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/CodeMemoryReportFormatter.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MemoryReportAllocator.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MemoryReportFormatter.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MemoryReporterPlugin.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockActualFunctionCall.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockExpectedFunctionCall.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockExpectedFunctionsList.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockFailure.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockFunctionCall.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockNamedValue.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockSupport.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockSupportPlugin.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/MockSupport_c.h
    incubator/celix/trunk/cmake/cpputest/include/CppUTestExt/OrderedTest.h
    incubator/celix/trunk/cmake/cpputest/include/Platforms/Gcc/Platform.h
    incubator/celix/trunk/cmake/cpputest/include/Platforms/StarterKit/Platform.h
    incubator/celix/trunk/cmake/cpputest/include/Platforms/Symbian/Platform.h
    incubator/celix/trunk/cmake/cpputest/include/Platforms/VisualCpp/Platform.h
    incubator/celix/trunk/cmake/cpputest/include/Platforms/VisualCpp/stdint.h
    incubator/celix/trunk/cmake/cpputest/lib/libCppUTest.a
    incubator/celix/trunk/cmake/cpputest/lib/libCppUTestExt.a
    incubator/celix/trunk/cmake/unity/colour_prompt.rb
    incubator/celix/trunk/cmake/unity/colour_reporter.rb
    incubator/celix/trunk/cmake/unity/generate_config.yml
    incubator/celix/trunk/cmake/unity/generate_module.rb
    incubator/celix/trunk/cmake/unity/generate_test_runner.rb
    incubator/celix/trunk/cmake/unity/src/unity.c
    incubator/celix/trunk/cmake/unity/src/unity.h
    incubator/celix/trunk/cmake/unity/src/unity_internals.h
    incubator/celix/trunk/cmake/unity/test_file_filter.rb
    incubator/celix/trunk/cmake/unity/unity_test_summary.rb
    incubator/celix/trunk/utils/private/test/testUnity.c
    incubator/celix/trunk/utils/private/test/testcpputest.cpp
    incubator/celix/trunk/utils/public/include/tomock.h
Modified:
    incubator/celix/trunk/CMakeLists.txt
    incubator/celix/trunk/framework/CMakeLists.txt
    incubator/celix/trunk/framework/private/src/version.c
    incubator/celix/trunk/framework/private/src/version_range.c
    incubator/celix/trunk/framework/private/src/wire.c
    incubator/celix/trunk/framework/public/include/version.h
    incubator/celix/trunk/remote_shell/private/src/shell_mediator.c
    incubator/celix/trunk/utils/CMakeLists.txt

Modified: incubator/celix/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/CMakeLists.txt?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/CMakeLists.txt (original)
+++ incubator/celix/trunk/CMakeLists.txt Wed Oct  2 09:05:31 2013
@@ -32,6 +32,8 @@ IF(WIN32)
 	SET(CMAKE_C_FLAGS "-D_CRT_SECURE_NO_WARNINGS ${CMAKE_C_FLAGS}")
 ENDIF()
 
+enable_testing()
+
 include(cmake/Includes.cmake)
 
 include(cmake/installation.cmake)

Modified: incubator/celix/trunk/framework/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/CMakeLists.txt?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/framework/CMakeLists.txt (original)
+++ incubator/celix/trunk/framework/CMakeLists.txt Wed Oct  2 09:05:31 2013
@@ -71,8 +71,21 @@ if (FRAMEWORK) 
     INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
     
     include_directories(${CUNIT_INCLUDE_DIRS})
+    include_directories(${CPPUTEST_INCLUDE_DIR})
+    include_directories(${CPPUTEST_EXT_INCLUDE_DIR})
+    
     add_executable(framework_test private/test/framework_test)
-    target_link_libraries(framework_test celix_utils celix_framework ${CUNIT_LIBRARIES})
+    target_link_libraries(framework_test celix_utils celix_framework ${CUNIT_LIBRARIES})
+    
+    add_executable(version_test private/test/version_test.cpp private/src/version.c)
+	target_link_libraries(version_test ${APR_LIBRARY} ${CPPUTEST_LIBRARY})
+	
+	add_executable(version_range_test private/test/version_range_test.cpp private/src/version_range.c)
+	target_link_libraries(version_range_test ${APR_LIBRARY} ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY})
     
-    run_test(framework_test)
+    run_test(framework_test)
+    
+    add_test(framework_test framework_test -ojunit)
+    add_test(version_test version_test -ojunit)
+    add_test(version_range_test version_range_test -ojunit)
 endif (FRAMEWORK)

Added: incubator/celix/trunk/framework/private/include/version_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/version_private.h?rev=1528385&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/include/version_private.h (added)
+++ incubator/celix/trunk/framework/private/include/version_private.h Wed Oct  2 09:05:31
2013
@@ -0,0 +1,43 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * version_private.h
+ *
+ *  \date       Dec 18, 2012
+ *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef VERSION_PRIVATE_H_
+#define VERSION_PRIVATE_H_
+
+#include "version.h"
+
+struct version {
+	apr_pool_t *pool;
+
+	int major;
+	int minor;
+	int micro;
+	char *qualifier;
+};
+
+
+#endif /* VERSION_PRIVATE_H_ */

Added: incubator/celix/trunk/framework/private/include/version_range_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/version_range_private.h?rev=1528385&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/include/version_range_private.h (added)
+++ incubator/celix/trunk/framework/private/include/version_range_private.h Wed Oct  2 09:05:31
2013
@@ -0,0 +1,41 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * version_range_private.h
+ *
+ *  \date       Dec 18, 2012
+ *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+
+#ifndef VERSION_RANGE_PRIVATE_H_
+#define VERSION_RANGE_PRIVATE_H_
+
+#include "version_range.h"
+
+struct versionRange {
+	version_t low;
+	bool isLowInclusive;
+	version_t high;
+	bool isHighInclusive;
+
+};
+
+#endif /* VERSION_RANGE_PRIVATE_H_ */

Modified: incubator/celix/trunk/framework/private/src/version.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/version.c?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version.c (original)
+++ incubator/celix/trunk/framework/private/src/version.c Wed Oct  2 09:05:31 2013
@@ -27,66 +27,65 @@
 #include <stdio.h>
 #include <apr_strings.h>
 
-#include "version.h"
 #include "celix_errno.h"
 #include "framework_log.h"
-
-
-struct version {
-	apr_pool_t *pool;
-
-	int major;
-	int minor;
-	int micro;
-	char *qualifier;
-};
+#include "version_private.h"
 
 static apr_status_t version_destroy(void *handle);
 
 celix_status_t version_createVersion(apr_pool_t *pool, int major, int minor, int micro, char
* qualifier, version_pt *version) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	*version = (version_pt) apr_palloc(pool, sizeof(**version));
-	if (!*version) {
-		status = CELIX_ENOMEM;
+	if (*version != NULL || pool == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
 	} else {
-		unsigned int i;
-		apr_pool_pre_cleanup_register(pool, *version, version_destroy);
-
-		(*version)->pool = pool;
-		(*version)->major = major;
-		(*version)->minor = minor;
-		(*version)->micro = micro;
-		if (qualifier == NULL) {
-			qualifier = "";
-		}
-		(*version)->qualifier = apr_pstrdup(pool, qualifier);
+		*version = (version_t) apr_palloc(pool, sizeof(**version));
+		if (!*version) {
+			status = CELIX_ENOMEM;
+		} else {
+			unsigned int i;
+			apr_pool_pre_cleanup_register(pool, *version, version_destroy);
 
-		if (major < 0) {
-			celix_log("Negative major");
-		}
-		if (minor < 0) {
-			celix_log("Negative minor");
-		}
-		if (micro < 0) {
-			celix_log("Negative micro");
-		}
-		
-		for (i = 0; i < strlen(qualifier); i++) {
-			char ch = qualifier[i];
-			if (('A' <= ch) && (ch <= 'Z')) {
-				continue;
-			}
-			if (('a' <= ch) && (ch <= 'z')) {
-				continue;
-			}
-			if (('0' <= ch) && (ch <= '9')) {
-				continue;
-			}
-			if ((ch == '_') || (ch == '-')) {
-				continue;
+			(*version)->pool = pool;
+			(*version)->major = major;
+			(*version)->minor = minor;
+			(*version)->micro = micro;
+			if (qualifier == NULL) {
+				qualifier = "";
+			}
+			(*version)->qualifier = apr_pstrdup(pool, qualifier);
+
+			if (major < 0) {
+				celix_log("Negative major");
+				status = CELIX_ILLEGAL_ARGUMENT;
+			}
+			if (minor < 0) {
+				celix_log("Negative minor");
+				status = CELIX_ILLEGAL_ARGUMENT;
+			}
+			if (micro < 0) {
+				celix_log("Negative micro");
+				status = CELIX_ILLEGAL_ARGUMENT;
+			}
+
+			for (i = 0; i < strlen(qualifier); i++) {
+				char ch = qualifier[i];
+				if (('A' <= ch) && (ch <= 'Z')) {
+					continue;
+				}
+				if (('a' <= ch) && (ch <= 'z')) {
+					continue;
+				}
+				if (('0' <= ch) && (ch <= '9')) {
+					continue;
+				}
+				if ((ch == '_') || (ch == '-')) {
+					continue;
+				}
+				celix_log("Invalid qualifier");
+				status = CELIX_ILLEGAL_ARGUMENT;
+				break;
 			}
-			celix_log("Invalid qualifier");
 		}
 	}
 
@@ -116,16 +115,45 @@ celix_status_t version_createVersionFrom
 
 	char delims[] = ".";
 	char *token = NULL;
-	char *last;
+	char *last = NULL;
+
+	int i = 0;
 
 	token = apr_strtok(versionStr, delims, &last);
 	if (token != NULL) {
+		for (i = 0; i < strlen(token); i++) {
+			char ch = token[i];
+			if (('0' <= ch) && (ch <= '9')) {
+				continue;
+			}
+			celix_log("Invalid format");
+			status = CELIX_ILLEGAL_ARGUMENT;
+			break;
+		}
 		major = atoi(token);
 		token = apr_strtok(NULL, delims, &last);
 		if (token != NULL) {
+			for (i = 0; i < strlen(token); i++) {
+				char ch = token[i];
+				if (('0' <= ch) && (ch <= '9')) {
+					continue;
+				}
+				celix_log("Invalid format");
+				status = CELIX_ILLEGAL_ARGUMENT;
+				break;
+			}
 			minor = atoi(token);
 			token = apr_strtok(NULL, delims, &last);
 			if (token != NULL) {
+				for (i = 0; i < strlen(token); i++) {
+					char ch = token[i];
+					if (('0' <= ch) && (ch <= '9')) {
+						continue;
+					}
+					celix_log("Invalid format");
+					status = CELIX_ILLEGAL_ARGUMENT;
+					break;
+				}
 				micro = atoi(token);
 				token = apr_strtok(NULL, delims, &last);
 				if (token != NULL) {
@@ -150,7 +178,35 @@ celix_status_t version_createEmptyVersio
 	return version_createVersion(pool, 0, 0, 0, "", version);
 }
 
+<<<<<<< HEAD
 celix_status_t version_compareTo(version_pt version, version_pt compare, int *result) {
+=======
+celix_status_t version_getMajor(version_t version, int *major) {
+	celix_status_t status = CELIX_SUCCESS;
+	*major = version->major;
+	return status;
+}
+
+celix_status_t version_getMinor(version_t version, int *minor) {
+	celix_status_t status = CELIX_SUCCESS;
+	*minor = version->minor;
+	return status;
+}
+
+celix_status_t version_getMicro(version_t version, int *micro) {
+	celix_status_t status = CELIX_SUCCESS;
+	*micro = version->micro;
+	return status;
+}
+
+celix_status_t version_getQualifier(version_t version, char **qualifier) {
+	celix_status_t status = CELIX_SUCCESS;
+	*qualifier = version->qualifier;
+	return status;
+}
+
+celix_status_t version_compareTo(version_t version, version_t compare, int *result) {
+>>>>>>> CELIX-55: Added tests, removed old unused files (test frameworks
etc).
 	celix_status_t status = CELIX_SUCCESS;
 	if (compare == version) {
 		*result = 0;

Modified: incubator/celix/trunk/framework/private/src/version_range.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/version_range.c?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version_range.c (original)
+++ incubator/celix/trunk/framework/private/src/version_range.c Wed Oct  2 09:05:31 2013
@@ -27,15 +27,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "version_range.h"
-
-struct versionRange {
-	version_pt low;
-	bool isLowInclusive;
-	version_pt high;
-	bool isHighInclusive;
-
-};
+#include "version_range_private.h"
 
 apr_status_t versionRange_destroy(void *rangeP);
 

Modified: incubator/celix/trunk/framework/private/src/wire.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/wire.c?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/wire.c (original)
+++ incubator/celix/trunk/framework/private/src/wire.c Wed Oct  2 09:05:31 2013
@@ -41,16 +41,20 @@ celix_status_t wire_create(apr_pool_t *p
 		module_pt exporter, capability_pt capability, wire_pt *wire) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	(*wire) = (wire_pt) apr_palloc(pool, sizeof(**wire));
-	if (!*wire) {
-		status = CELIX_ENOMEM;
+	if (*wire != NULL || pool == NULL) {
+		status = CELIX_ILLEGAL_ARGUMENT;
 	} else {
-		apr_pool_pre_cleanup_register(pool, *wire, wire_destroy);
-
-		(*wire)->importer = importer;
-		(*wire)->requirement = requirement;
-		(*wire)->exporter = exporter;
-		(*wire)->capability = capability;
+		(*wire) = (wire_t) apr_palloc(pool, sizeof(**wire));
+		if (!*wire) {
+			status = CELIX_ENOMEM;
+		} else {
+			apr_pool_pre_cleanup_register(pool, *wire, wire_destroy);
+
+			(*wire)->importer = importer;
+			(*wire)->requirement = requirement;
+			(*wire)->exporter = exporter;
+			(*wire)->capability = capability;
+		}
 	}
 
 	return status;

Added: incubator/celix/trunk/framework/private/test/version_range_test.cpp
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/test/version_range_test.cpp?rev=1528385&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/test/version_range_test.cpp (added)
+++ incubator/celix/trunk/framework/private/test/version_range_test.cpp Wed Oct  2 09:05:31
2013
@@ -0,0 +1,189 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * version_range_test.cpp
+ *
+ *  \date       Dec 18, 2012
+ *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include <apr_strings.h>
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+#include "CppUTestExt/MockSupport.h"
+
+extern "C"
+{
+	#include "CppUTestExt/MockSupport_c.h"
+
+	#include "version_range_private.h"
+	#include "version_private.h"
+
+	celix_status_t version_createEmptyVersion(apr_pool_t *pool, version_t *version) {
+		mock_c()->actualCall("version_createEmptyVersion")
+				->withPointerParameters("pool", pool)
+				->_andPointerOutputParameters("version", (void **) version);
+		return CELIX_SUCCESS;
+	}
+
+	celix_status_t version_compareTo(version_t version, version_t compare, int *result) {
+//		*result = (int) mock_c()->getData("result").value.intValue;
+		mock_c()->actualCall("version_compareTo")
+			->withPointerParameters("version", version)
+			->withPointerParameters("compare", compare)
+			->_andIntOutputParameters("result", result);
+		return CELIX_SUCCESS;
+	}
+
+	celix_status_t version_createVersionFromString(apr_pool_t *pool, char * versionStr, version_t
*version) {
+		mock_c()->actualCall("version_createVersionFromString")
+			->withPointerParameters("pool", pool)
+			->withStringParameters("versionStr", versionStr)
+			->_andPointerOutputParameters("version", (void **) version);
+		return CELIX_SUCCESS;
+	}
+}
+
+int main(int argc, char** argv) {
+	return RUN_ALL_TESTS(argc, argv);
+}
+
+TEST_GROUP(version_range) {
+	apr_pool_t *pool;
+
+	void setup(void) {
+		apr_initialize();
+		apr_pool_create(&pool, NULL);
+	}
+
+	void teardown() {
+		apr_pool_destroy(pool);
+		mock().checkExpectations();
+		mock().clear();
+	}
+};
+
+TEST(version_range, create) {
+	celix_status_t status = APR_SUCCESS;
+	version_range_t range = NULL;
+	version_t version = (version_t) apr_palloc(pool, sizeof(*version));
+
+	status = versionRange_createVersionRange(pool, version, false, version, true, &range);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C((range != NULL));
+	LONGS_EQUAL(true, range->isHighInclusive);
+	LONGS_EQUAL(false, range->isLowInclusive);
+	POINTERS_EQUAL(version, range->low);
+	POINTERS_EQUAL(version, range->high);
+}
+
+TEST(version_range, createInfinite) {
+	celix_status_t status = APR_SUCCESS;
+	version_range_t range = NULL;
+	version_t version = (version_t) apr_palloc(pool, sizeof(*version));
+	version->major = 1;
+	version->minor = 2;
+	version->micro = 3;
+
+	mock()
+		.expectOneCall("version_createEmptyVersion")
+		.withParameter("pool", pool)
+		.andOutputParameter("version", version);
+	status = versionRange_createInfiniteVersionRange(pool, &range);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(range != NULL);
+	LONGS_EQUAL(true, range->isHighInclusive);
+	LONGS_EQUAL(true, range->isLowInclusive);
+	POINTERS_EQUAL(version, range->low);
+	POINTERS_EQUAL(NULL, range->high);
+}
+
+TEST(version_range, isInRange) {
+	celix_status_t status = APR_SUCCESS;
+	version_range_t range = NULL;
+	version_t version = (version_t) apr_palloc(pool, sizeof(*version));
+	version->major = 1;
+	version->minor = 2;
+	version->micro = 3;
+
+	version_t low = (version_t) apr_palloc(pool, sizeof(*low));
+	low->major = 1;
+	low->minor = 2;
+	low->micro = 3;
+
+	version_t high = (version_t) apr_palloc(pool, sizeof(*high));
+	high->major = 1;
+	high->minor = 2;
+	high->micro = 3;
+
+	versionRange_createVersionRange(pool, low, true, high, true, &range);
+
+	mock()
+		.expectOneCall("version_compareTo")
+		.withParameter("version", version)
+		.withParameter("compare", low)
+		.andOutputParameter("result", 1);
+	mock()
+		.expectOneCall("version_compareTo")
+		.withParameter("version", version)
+		.withParameter("compare", high)
+		.andOutputParameter("result", -1);
+
+	bool result;
+	status = versionRange_isInRange(range, version, &result);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(true, result);
+}
+
+TEST(version_range, parse) {
+	celix_status_t status = APR_SUCCESS;
+	version_range_t range = NULL;
+	version_t low = (version_t) apr_palloc(pool, sizeof(*low));
+	version_t high = (version_t) apr_palloc(pool, sizeof(*high));
+
+	low->major = 1;
+	low->minor = 2;
+	low->micro = 3;
+
+	high->major = 7;
+	high->minor = 8;
+	high->micro = 9;
+
+	mock().strictOrder();
+	mock()
+		.expectOneCall("version_createVersionFromString")
+		.withParameter("pool", pool)
+		.withParameter("versionStr", "1.2.3")
+		.andOutputParameter("version", low);
+	mock()
+		.expectOneCall("version_createVersionFromString")
+		.withParameter("pool", pool)
+		.withParameter("versionStr", "7.8.9")
+		.andOutputParameter("version", high);
+
+	status = versionRange_parse(pool, "[1.2.3, 7.8.9]", &range);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+}
+
+
+
+

Added: incubator/celix/trunk/framework/private/test/version_test.cpp
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/test/version_test.cpp?rev=1528385&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/test/version_test.cpp (added)
+++ incubator/celix/trunk/framework/private/test/version_test.cpp Wed Oct  2 09:05:31 2013
@@ -0,0 +1,296 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * version_test.cpp
+ *
+ *  \date       Dec 18, 2012
+ *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+#include <apr_strings.h>
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+
+extern "C"
+{
+#include "version_private.h"
+}
+
+int main(int argc, char** argv) {
+	return RUN_ALL_TESTS(argc, argv);
+}
+
+TEST_GROUP(version) {
+	apr_pool_t *pool;
+
+	void setup(void) {
+		apr_initialize();
+		apr_pool_create(&pool, NULL);
+	}
+
+	void teardown() {
+		apr_pool_destroy(pool);
+	}
+};
+
+
+TEST(version, create) {
+	version_t version = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	std::string str;
+
+	str = "abc";
+	status = version_createVersion(NULL, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	str = "abc";
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+    LONGS_EQUAL(1, version->major);
+	LONGS_EQUAL(2, version->minor);
+	LONGS_EQUAL(3, version->micro);
+	STRCMP_EQUAL("abc", version->qualifier);
+
+	version = NULL;
+	status = version_createVersion(pool, 1, 2, 3, NULL, &version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+	LONGS_EQUAL(1, version->major);
+	LONGS_EQUAL(2, version->minor);
+	LONGS_EQUAL(3, version->micro);
+	STRCMP_EQUAL("", version->qualifier);
+
+	str = "abc";
+	status = version_createVersion(pool, 1, -2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	str = "abc|xyz";
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+}
+
+TEST(version, clone) {
+	version_t version = NULL, clone = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	std::string str;
+
+	str = "abc";
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	status = version_clone(version, pool, &clone);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+    LONGS_EQUAL(1, clone->major);
+	LONGS_EQUAL(2, clone->minor);
+	LONGS_EQUAL(3, clone->micro);
+	STRCMP_EQUAL("abc", clone->qualifier);
+}
+
+TEST(version, createFromString) {
+	version_t version = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	std::string str;
+
+	str = "1";
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+	LONGS_EQUAL(1, version->major);
+
+	str = "a";
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	str = "1.a";
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	str = "1.1.a";
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	str = "-1";
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+
+	str = "1.2";
+	version = NULL;
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+	LONGS_EQUAL(1, version->major);
+	LONGS_EQUAL(2, version->minor);
+
+	str = "1.2.3";
+	version = NULL;
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+	LONGS_EQUAL(1, version->major);
+	LONGS_EQUAL(2, version->minor);
+	LONGS_EQUAL(3, version->micro);
+
+	str = "1.2.3.abc";
+	version = NULL;
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+    LONGS_EQUAL(1, version->major);
+	LONGS_EQUAL(2, version->minor);
+	LONGS_EQUAL(3, version->micro);
+	STRCMP_EQUAL("abc", version->qualifier);
+
+	str = "1.2.3.abc_xyz";
+	version = NULL;
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+    LONGS_EQUAL(1, version->major);
+	LONGS_EQUAL(2, version->minor);
+	LONGS_EQUAL(3, version->micro);
+	STRCMP_EQUAL("abc_xyz", version->qualifier);
+
+	str = "1.2.3.abc-xyz";
+	version = NULL;
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+    LONGS_EQUAL(1, version->major);
+	LONGS_EQUAL(2, version->minor);
+	LONGS_EQUAL(3, version->micro);
+	STRCMP_EQUAL("abc-xyz", version->qualifier);
+
+	str = "1.2.3.abc|xyz";
+	status = version_createVersionFromString(pool, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+}
+
+TEST(version, createEmptyVersion) {
+	version_t version = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+
+	status = version_createEmptyVersion(pool, &version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+    LONGS_EQUAL(0, version->major);
+	LONGS_EQUAL(0, version->minor);
+	LONGS_EQUAL(0, version->micro);
+	STRCMP_EQUAL("", version->qualifier);
+}
+
+TEST(version, getters) {
+	version_t version = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	std::string str;
+	int major, minor, micro;
+	char *qualifier;
+
+	str = "abc";
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+
+	version_getMajor(version, &major);
+    LONGS_EQUAL(1, major);
+
+    version_getMinor(version, &minor);
+	LONGS_EQUAL(2, minor);
+
+	version_getMicro(version, &micro);
+	LONGS_EQUAL(3, micro);
+
+	version_getQualifier(version, &qualifier);
+	STRCMP_EQUAL("abc", qualifier);
+}
+
+TEST(version, compare) {
+	version_t version = NULL, compare = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	std::string str;
+	int result;
+
+	// Base version to compare
+	str = "abc";
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+
+	// Compare equality
+	str = "abc";
+	compare = NULL;
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&compare);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+	status = version_compareTo(version, compare, &result);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	LONGS_EQUAL(0, result);
+
+	// Compare against a higher version
+	str = "bcd";
+	compare = NULL;
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&compare);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+	status = version_compareTo(version, compare, &result);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK(result < 0);
+
+	// Compare againts a lower version
+	str = "abc";
+	compare = NULL;
+	status = version_createVersion(pool, 1, 1, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&compare);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+	status = version_compareTo(version, compare, &result);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK(result > 0);
+}
+
+TEST(version, toString) {
+	version_t version = NULL, compare = NULL;
+	celix_status_t status = CELIX_SUCCESS;
+	std::string str;
+	char *result = NULL;
+
+	str = "abc";
+	status = version_createVersion(pool, 1, 2, 3, apr_pstrdup(pool, (const char *) str.c_str()),
&version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+
+	status = version_toString(version, pool, &result);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(result != NULL);
+	STRCMP_EQUAL("1.2.3.abc", result);
+
+	version = NULL;
+	status = version_createVersion(pool, 1, 2, 3, NULL, &version);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(version != NULL);
+
+	status = version_toString(version, pool, &result);
+	LONGS_EQUAL(CELIX_SUCCESS, status);
+	CHECK_C(result != NULL);
+	STRCMP_EQUAL("1.2.3", result);
+}
+
+
+

Modified: incubator/celix/trunk/framework/public/include/version.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/version.h?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/version.h (original)
+++ incubator/celix/trunk/framework/public/include/version.h Wed Oct  2 09:05:31 2013
@@ -100,7 +100,7 @@ celix_status_t version_clone(version_pt 
  * 		- CELIX_SUCCESS when no errors are encountered.
  * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
  * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
- * 		  	the qualifier string is invalid or <code>versionStr</code> is impropertly
formatted.
+ * 		  	the qualifier string is invalid or <code>versionStr</code> is improperly
formatted.
  */
 celix_status_t version_createVersionFromString(apr_pool_t *pool, char * versionStr, version_pt
*version);
 
@@ -113,10 +113,15 @@ celix_status_t version_createVersionFrom
  * 		- CELIX_SUCCESS when no errors are encountered.
  * 		- CELIX_ENOMEM If allocating memory for <code>version</code> failed.
  * 		- CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
- * 		  	the qualifier string is invalid or <code>versionStr</code> is impropertly
formatted.
+ * 		  	the qualifier string is invalid or <code>versionStr</code> is improperly
formatted.
  */
 celix_status_t version_createEmptyVersion(apr_pool_t *pool, version_pt *version);
 
+celix_status_t version_getMajor(version_t version, int *major);
+celix_status_t version_getMinor(version_t version, int *minor);
+celix_status_t version_getMicro(version_t version, int *micro);
+celix_status_t version_getQualifier(version_t version, char **qualifier);
+
 /**
  * Compares this <code>Version</code> object to another object.
  *

Modified: incubator/celix/trunk/remote_shell/private/src/shell_mediator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_shell/private/src/shell_mediator.c?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/remote_shell/private/src/shell_mediator.c (original)
+++ incubator/celix/trunk/remote_shell/private/src/shell_mediator.c Wed Oct  2 09:05:31 2013
@@ -62,7 +62,7 @@ celix_status_t shellMediator_create(apr_
 	celix_status_t status = CELIX_SUCCESS;
 	service_tracker_customizer_pt customizer = NULL;
 
-	(*instance) = (shell_mediator_pt) (pool, sizeof(**instance));
+	(*instance) = (shell_mediator_t) apr_palloc(pool, sizeof(**instance));
     if ((*instance) != NULL) {
 		apr_pool_pre_cleanup_register(pool, *instance, shellMediator_cleanup);
 

Modified: incubator/celix/trunk/utils/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/CMakeLists.txt?rev=1528385&r1=1528384&r2=1528385&view=diff
==============================================================================
--- incubator/celix/trunk/utils/CMakeLists.txt (original)
+++ incubator/celix/trunk/utils/CMakeLists.txt Wed Oct  2 09:05:31 2013
@@ -1,83 +1,79 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-# 
-#   http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-celix_subproject(UTILS "Option to build the utilities library" "ON")
-if (UTILS) 
-    cmake_minimum_required(VERSION 2.6)
-    
-    add_definitions(-DUSE_FILE32API)
-    #aux_source_directory("private/src" SRC)
-    include_directories("private/include")
-    include_directories("public/include")
-    add_library(celix_utils SHARED 
-		private/src/array_list.c
-		public/include/array_list.h 
-		private/include/array_list_private.h 
-
-		private/src/hash_map.c
-		public/include/hash_map.h 
-		private/include/hash_map_private.h
-
-		private/src/linkedlist.c
-		private/src/linked_list_iterator.c
-		public/include/linkedlist.h
-		public/include/linked_list_iterator.h 
-		private/include/linked_list_private.h
-		
-		public/include/exports.h
-	)
-    
-    IF(UNIX)
-    	target_link_libraries(celix_utils m)
-    ENDIF(UNIX)
-    target_link_libraries(celix_utils ${APR_LIBRARY})
-    
-    install(TARGETS celix_utils DESTINATION lib COMPONENT framework)
-    FILE(GLOB files "public/include/*.h")
-    INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
-    
-    include_directories(${CUNIT_INCLUDE_DIRS})
-    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-    include_directories("${PROJECT_SOURCE_DIR}/utils/private/include")
-    
-    add_executable(hash_map_test private/test/hash_map_test.c)
-    target_link_libraries(hash_map_test celix_utils ${CUNIT_LIBRARIES})
-    
-    add_executable(hash_map_test_hash private/test/hash_map_test_hash.c)
-    target_link_libraries(hash_map_test_hash celix_utils ${CUNIT_LIBRARIES})
-    
-    add_executable(array_list_test private/test/array_list_test.c)
-    target_link_libraries(array_list_test celix_utils ${CUNIT_LIBRARIES})
-    
-    add_executable(linked_list_test private/test/linked_list_test.c)
-    target_link_libraries(linked_list_test celix_utils ${CUNIT_LIBRARIES})
-    
-    run_test(array_list_test)
-    run_test(hash_map_test)
-    run_test(hash_map_test_hash)
-    run_test(linked_list_test)
-    
-    #run_unity_test(unity_bla SOURCE private/test/testUnity.c MOCKS public/include/tomock.h)
-    #add_test(unity_bla ${CMAKE_CURRENT_BINARY_DIR}/unity_bla)
-    
-    #SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fnested-functions ${CMAKE_C_FLAGS}")
-    
-    #include_directories(${PROJECT_SOURCE_DIR}/cmake/cpputest/include)
-    #link_directories(${PROJECT_SOURCE_DIR}/cmake/cpputest/lib)
-    #add_executable(testcpputest private/test/testcpputest.cpp)
-    #target_link_libraries(testcpputest CppUTest CppUTestExt)
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+celix_subproject(UTILS "Option to build the utilities library" "ON")
+if (UTILS) 
+    cmake_minimum_required(VERSION 2.6)
+    
+    add_definitions(-DUSE_FILE32API)
+    #aux_source_directory("private/src" SRC)
+    include_directories("private/include")
+    include_directories("public/include")
+    add_library(celix_utils SHARED 
+		private/src/array_list.c
+		public/include/array_list.h 
+		private/include/array_list_private.h 
+
+		private/src/hash_map.c
+		public/include/hash_map.h 
+		private/include/hash_map_private.h
+
+		private/src/linkedlist.c
+		private/src/linked_list_iterator.c
+		public/include/linkedlist.h
+		public/include/linked_list_iterator.h 
+		private/include/linked_list_private.h
+		
+		public/include/exports.h
+	)
+    
+    IF(UNIX)
+    	target_link_libraries(celix_utils m)
+    ENDIF(UNIX)
+    target_link_libraries(celix_utils ${APR_LIBRARY})
+    
+    install(TARGETS celix_utils DESTINATION lib COMPONENT framework)
+    FILE(GLOB files "public/include/*.h")
+    INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
+    
+    include_directories(${CUNIT_INCLUDE_DIRS})
+    include_directories(${CPPUTEST_INCLUDE_DIR})
+    include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+    include_directories("${PROJECT_SOURCE_DIR}/utils/private/include")
+    
+    add_executable(hash_map_test private/test/hash_map_test.c)
+    target_link_libraries(hash_map_test celix_utils ${CUNIT_LIBRARIES})
+    
+    add_executable(hash_map_test_hash private/test/hash_map_test_hash.c)
+    target_link_libraries(hash_map_test_hash celix_utils ${CUNIT_LIBRARIES})
+    
+    add_executable(array_list_test2 private/test/array_list_test.c)
+    target_link_libraries(array_list_test2 celix_utils ${CUNIT_LIBRARIES})
+    
+    add_executable(array_list_test private/test/array_list_test.cpp)
+	target_link_libraries(array_list_test celix_utils ${CPPUTEST_LIBRARY})
+    
+    add_executable(linked_list_test private/test/linked_list_test.c)
+    target_link_libraries(linked_list_test celix_utils ${CUNIT_LIBRARIES})
+    
+    run_test(array_list_test)
+    run_test(hash_map_test)
+    run_test(hash_map_test_hash)
+    run_test(linked_list_test)
+    
+    add_test(array_list_test array_list_test -ojunit)
 endif (UTILS)

Added: incubator/celix/trunk/utils/private/test/array_list_test.cpp
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/test/array_list_test.cpp?rev=1528385&view=auto
==============================================================================
--- incubator/celix/trunk/utils/private/test/array_list_test.cpp (added)
+++ incubator/celix/trunk/utils/private/test/array_list_test.cpp Wed Oct  2 09:05:31 2013
@@ -0,0 +1,107 @@
+/*
+ * array_list_test.cpp
+ *
+ *  Created on: Jun 6, 2012
+ *      Author: alexander
+ */
+
+#include "CPPUTest/TestHarness.h"
+#include "CPPUTest/TestHarness_c.h"
+#include "CPPUTest/CommandLineTestRunner.h"
+
+extern "C"
+{
+#include "array_list.h"
+#include "array_list_private.h"
+}
+
+int main(int argc, char** argv) {
+	return RUN_ALL_TESTS(argc, argv);
+}
+
+TEST_GROUP(array_list) {
+	array_list_t list;
+	apr_pool_t *pool;
+
+	void setup(void) {
+		apr_initialize();
+		apr_pool_create(&pool, NULL);
+
+		arrayList_create(pool, &list);
+	}
+};
+
+
+TEST(array_list, create) {
+	CHECK_C(list != NULL);
+    LONGS_EQUAL(0, list->size);
+}
+
+TEST(array_list, trimToSize) {
+	bool added;
+	char * entry;
+	arrayList_clear(list);
+
+	entry = "entry";
+	added = arrayList_add(list, entry);
+	LONGS_EQUAL(list->size, 1);
+	LONGS_EQUAL(list->capacity, 10);
+
+	arrayList_trimToSize(list);
+	LONGS_EQUAL(list->size, 1);
+	LONGS_EQUAL(list->capacity, 1);
+}
+
+TEST(array_list, ensureCapacity) {
+	int i;
+	arrayList_create(pool, &list);
+	arrayList_clear(list);
+
+	LONGS_EQUAL(list->capacity, 10);
+	LONGS_EQUAL(list->size, 0);
+
+	for (i = 0; i < 100; i++) {
+		bool added;
+		char *entry = "entry";
+		added = arrayList_add(list, entry);
+	}
+	LONGS_EQUAL(list->capacity, 133);
+	LONGS_EQUAL(list->size, 100);
+	arrayList_create(pool, &list);
+}
+
+TEST(array_list, clone) {
+	int i;
+	arrayList_create(pool, &list);
+	arrayList_clear(list);
+
+	LONGS_EQUAL(list->capacity, 10);
+	LONGS_EQUAL(list->size, 0);
+
+	for (i = 0; i < 12; i++) {
+		bool added;
+		char entry[11];
+		sprintf(entry, "|%s|%d|", "entry", i);
+		added = arrayList_add(list, strdup(entry));
+	}
+	LONGS_EQUAL(16, list->capacity);
+	LONGS_EQUAL(12, list->size);
+
+	array_list_t clone = NULL;
+	clone = arrayList_clone(pool, list);
+
+	LONGS_EQUAL(16, clone->capacity);
+	LONGS_EQUAL(12, clone->size);
+
+	unsigned int j;
+	for (j = 0; j < 12; j++) {
+		void *entry = NULL;
+		char entrys[11];
+		sprintf(entrys, "|%s|%d|", "entry", j);
+
+		entry = arrayList_get(clone, j);
+		STRCMP_EQUAL((char *) entry, entrys);
+	}
+
+	arrayList_create(pool, &list);
+}



Mime
View raw message