Author: abroekhuis
Date: Mon Jun 20 13:34:49 2011
New Revision: 1137628
URL: http://svn.apache.org/viewvc?rev=1137628&view=rev
Log:
Applied patch from CELIX-6. Updated some cmake scripts to support multiple
platforms.
Modified:
incubator/celix/trunk/.cproject
incubator/celix/trunk/.settings/org.eclipse.cdt.codan.core.prefs
incubator/celix/trunk/CMakeLists.txt
incubator/celix/trunk/celix_test/array_list_test.c
incubator/celix/trunk/celix_test/hash_map_test.c
incubator/celix/trunk/celix_test/hash_map_test_hash.c
incubator/celix/trunk/cmake/modules/FindCUnit.cmake
incubator/celix/trunk/utils/private/include/hash_map_private.h
incubator/celix/trunk/utils/private/src/hash_map.c
incubator/celix/trunk/utils/public/include/array_list.h
Modified: incubator/celix/trunk/.cproject
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/.cproject?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/.cproject (original)
+++ incubator/celix/trunk/.cproject Mon Jun 20 13:34:49 2011
@@ -40,6 +40,7 @@
<option
id="gnu.c.compiler.option.include.paths.544783026" name="Include paths (-I)"
superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/opt/local/include"/>
<listOptionValue builtIn="false" value="/usr/include/apr-1"/>
+
<listOptionValue builtIn="false" value="/opt/local/include/CUnit"/>
</option>
<inputType
id="cdt.managedbuild.tool.gnu.c.compiler.input.1627566234"
superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
Modified: incubator/celix/trunk/.settings/org.eclipse.cdt.codan.core.prefs
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/.settings/org.eclipse.cdt.codan.core.prefs?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/.settings/org.eclipse.cdt.codan.core.prefs (original)
+++ incubator/celix/trunk/.settings/org.eclipse.cdt.codan.core.prefs Mon Jun 20
13:34:49 2011
@@ -1,4 +1,4 @@
-#Wed Apr 13 14:04:28 CEST 2011
+#Mon Jun 20 15:12:11 CEST 2011
eclipse.preferences.version=1
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false}
@@ -6,6 +6,8 @@ org.eclipse.cdt.codan.checkers.errreturn
org.eclipse.cdt.codan.checkers.errreturnvalue.params={}
org.eclipse.cdt.codan.checkers.noreturn=Error
org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false}
+org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
+org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
@@ -13,7 +15,7 @@ org.eclipse.cdt.codan.internal.checkers.
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={}
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no
break",last_case_param\=>true,empty_case_param\=>false}
+org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>nb,last_case_param\=>true,empty_case_param\=>false}
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
@@ -51,8 +53,15 @@ org.eclipse.cdt.codan.internal.checkers.
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false}
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false}
+org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false}
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={exceptions\=>("@(\#)","$Id")}
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+useParentScope=true
Modified: incubator/celix/trunk/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/CMakeLists.txt?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/CMakeLists.txt (original)
+++ incubator/celix/trunk/CMakeLists.txt Mon Jun 20 13:34:49 2011
@@ -23,7 +23,7 @@ project (Celix C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/modules/")
SET(CMAKE_BUILD_TYPE "Debug")
-SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=c99")
+SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99")
SET(CMAKE_INSTALL_COMPONENT "framework")
ADD_CUSTOM_TARGET(install-fw
Modified: incubator/celix/trunk/celix_test/array_list_test.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/celix_test/array_list_test.c?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/celix_test/array_list_test.c (original)
+++ incubator/celix/trunk/celix_test/array_list_test.c Mon Jun 20 13:34:49 2011
@@ -23,9 +23,9 @@
* Author: alexanderb
*/
#include <stdio.h>
-#include <stdbool.h>
+#include <Automated.h>
-#include "CUnit/Basic.h"
+#include "celixbool.h"
#include "array_list.h"
#include "array_list_private.h"
@@ -46,9 +46,10 @@ void test_arrayList_create(void) {
}
void test_arrayList_trimToSize(void) {
+ char * entry;
arrayList_clear(list);
- char * entry = "entry";
+ entry = "entry";
arrayList_add(list, entry);
CU_ASSERT_EQUAL(list->size, 1);
CU_ASSERT_EQUAL(list->capacity, 10);
@@ -59,11 +60,11 @@ void test_arrayList_trimToSize(void) {
}
void test_arrayList_ensureCapacity(void) {
+ int i;
list = arrayList_create();
arrayList_clear(list);
CU_ASSERT_EQUAL(list->capacity, 10);
CU_ASSERT_EQUAL(list->size, 0);
- int i;
for (i = 0; i < 100; i++) {
arrayList_add(list, "entry");
}
@@ -73,18 +74,21 @@ void test_arrayList_ensureCapacity(void)
}
void test_arrayList_size(void) {
+ char * entry;
+ char * entry2;
+ char * entry3;
arrayList_clear(list);
CU_ASSERT_EQUAL(list->size, 0);
- char * entry = "entry";
+ entry = "entry";
arrayList_add(list, entry);
CU_ASSERT_EQUAL(list->size, 1);
- char * entry2 = "entry";
+ entry2 = "entry";
arrayList_add(list, entry2);
CU_ASSERT_EQUAL(list->size, 2);
- char * entry3 = "entry";
+ entry3 = "entry";
arrayList_add(list, entry3);
CU_ASSERT_EQUAL(list->size, 3);
}
@@ -96,32 +100,35 @@ void test_arrayList_isEmpty(void) {
}
void test_arrayList_contains(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+ char * entry3 = NULL;
+ bool contains;
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
CU_ASSERT_TRUE(arrayList_contains(list, entry));
CU_ASSERT_TRUE(arrayList_contains(list, entry2));
- bool contains = arrayList_contains(list, NULL);
+ contains = arrayList_contains(list, NULL);
CU_ASSERT_FALSE(contains);
- char * entry3 = NULL;
arrayList_add(list, entry3);
CU_ASSERT_TRUE(arrayList_contains(list, entry3));
}
void test_arrayList_indexOf(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
arrayList_add(list, entry2);
arrayList_add(list, entry2);
@@ -134,20 +141,22 @@ void test_arrayList_indexOf(void) {
}
void test_arrayList_get(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+ char * entry3 = NULL;
+ char * get;
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
- char * get = arrayList_get(list, 0);
+ get = arrayList_get(list, 0);
CU_ASSERT_EQUAL(entry, get);
get = arrayList_get(list, 1);
CU_ASSERT_EQUAL(entry2, get);
- char * entry3 = NULL;
arrayList_add(list, entry3);
get = arrayList_get(list, 2);
@@ -158,35 +167,40 @@ void test_arrayList_get(void) {
}
void test_arrayList_set(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+ char * entry3 = "entry3";
+ char * get;
+ char * old;
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
- char * get = arrayList_get(list, 1);
+ get = arrayList_get(list, 1);
CU_ASSERT_EQUAL(entry2, get);
- char * entry3 = "entry3";
- char * old = arrayList_set(list, 1, entry3);
+ old = arrayList_set(list, 1, entry3);
CU_ASSERT_EQUAL(entry2, old);
get = arrayList_get(list, 1);
CU_ASSERT_EQUAL(entry3, get);
}
void test_arrayList_add(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+ char * entry3 = "entry3";
+ char * get;
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
- char * get = arrayList_get(list, 1);
+ get = arrayList_get(list, 1);
CU_ASSERT_EQUAL(entry2, get);
- char * entry3 = "entry3";
arrayList_addIndex(list, 1, entry3);
get = arrayList_get(list, 1);
@@ -197,21 +211,25 @@ void test_arrayList_add(void) {
}
void test_arrayList_addAll(void) {
- arrayList_clear(list);
-
- ARRAY_LIST toAdd = arrayList_create();
char * entry = "entry";
- arrayList_add(toAdd, entry);
char * entry2 = "entry2";
+ char * entry3 = "entry3";
+ char * get;
+ ARRAY_LIST toAdd;
+ bool changed;
+
+ arrayList_clear(list);
+
+ toAdd = arrayList_create();
+ arrayList_add(toAdd, entry);
arrayList_add(toAdd, entry2);
- char * entry3 = "entry3";
arrayList_add(list, entry3);
- char * get = arrayList_get(list, 0);
+ get = arrayList_get(list, 0);
CU_ASSERT_EQUAL(entry3, get);
- bool changed = arrayList_addAll(list, toAdd);
+ changed = arrayList_addAll(list, toAdd);
CU_ASSERT_TRUE(changed);
CU_ASSERT_EQUAL(arrayList_size(list), 3);
@@ -223,18 +241,22 @@ void test_arrayList_addAll(void) {
}
void test_arrayList_remove(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+ char * entry3 = "entry3";
+ char * get;
+ char * removed;
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
- char * get = arrayList_get(list, 1);
+ get = arrayList_get(list, 1);
CU_ASSERT_EQUAL(entry2, get);
// Remove first entry
- char * removed = arrayList_remove(list, 0);
+ removed = arrayList_remove(list, 0);
CU_ASSERT_EQUAL(entry, removed);
// Check the new first element
@@ -242,7 +264,6 @@ void test_arrayList_remove(void) {
CU_ASSERT_EQUAL(entry2, get);
// Add a new element
- char * entry3 = "entry3";
arrayList_add(list, entry3);
get = arrayList_get(list, 1);
@@ -250,22 +271,24 @@ void test_arrayList_remove(void) {
}
void test_arrayList_removeElement(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+ char * entry3 = "entry3";
+ char * get;
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
// Remove entry
CU_ASSERT_TRUE(arrayList_removeElement(list, entry));
// Check the new first element
- char * get = arrayList_get(list, 0);
+ get = arrayList_get(list, 0);
CU_ASSERT_EQUAL(entry2, get);
// Add a new element
- char * entry3 = "entry3";
arrayList_add(list, entry3);
get = arrayList_get(list, 1);
@@ -273,11 +296,12 @@ void test_arrayList_removeElement(void)
}
void test_arrayList_clear(void) {
+ char * entry = "entry";
+ char * entry2 = "entry2";
+
arrayList_clear(list);
- char * entry = "entry";
arrayList_add(list, entry);
- char * entry2 = "entry2";
arrayList_add(list, entry2);
CU_ASSERT_EQUAL(arrayList_size(list), 2);
Modified: incubator/celix/trunk/celix_test/hash_map_test.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/celix_test/hash_map_test.c?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/celix_test/hash_map_test.c (original)
+++ incubator/celix/trunk/celix_test/hash_map_test.c Mon Jun 20 13:34:49 2011
@@ -23,9 +23,9 @@
* Author: alexanderb
*/
#include <stdio.h>
-#include <stdbool.h>
+#include <Basic.h>
-#include "CUnit/Basic.h"
+#include "celixbool.h"
#include "hash_map.h"
#include "hash_map_private.h"
@@ -44,6 +44,7 @@ int setup(void) {
void test_hashMap_create(void) {
CU_ASSERT_PTR_NOT_NULL_FATAL(map);
CU_ASSERT_EQUAL(map->size, 0);
+ // This fails on windows due to dllimport providing a proxy for
exported functions.
CU_ASSERT_EQUAL(map->equalsKey, hashMap_equals);
CU_ASSERT_EQUAL(map->equalsValue, hashMap_equals);
CU_ASSERT_EQUAL(map->hashKey, hashMap_hashCode);
@@ -51,23 +52,24 @@ void test_hashMap_create(void) {
}
void test_hashMap_size(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char * key3 = "key2";
+ char * value3 = "value3";
+
CU_ASSERT_EQUAL(map->size, 0);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
CU_ASSERT_EQUAL(map->size, 1);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
CU_ASSERT_EQUAL(map->size, 2);
// Overwrite existing entry
- char * key3 = "key2";
- char * value3 = "value3";
hashMap_put(map, key3, value3);
CU_ASSERT_EQUAL(map->size, 2);
@@ -77,13 +79,14 @@ void test_hashMap_size(void) {
}
void test_hashMap_isEmpty(void) {
+ char * key = "key";
+ char * value = "value";
+
hashMap_clear(map, false, false);
CU_ASSERT_EQUAL(map->size, 0);
CU_ASSERT_TRUE(hashMap_isEmpty(map));
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
CU_ASSERT_EQUAL(map->size, 1);
CU_ASSERT_FALSE(hashMap_isEmpty(map));
@@ -95,25 +98,29 @@ void test_hashMap_isEmpty(void) {
}
void test_hashMap_get(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char * neKey = "notExisting";
+ char * key3 = NULL;
+ char * value3 = "value3";
+ char * get;
+
hashMap_clear(map, false, false);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
- char * get = hashMap_get(map, key);
+ get = hashMap_get(map, key);
CU_ASSERT_STRING_EQUAL(get, value);
get = hashMap_get(map, key2);
CU_ASSERT_STRING_EQUAL(get, value2);
- char * neKey = "notExisting";
get = hashMap_get(map, neKey);
CU_ASSERT_EQUAL(get, NULL);
@@ -121,8 +128,6 @@ void test_hashMap_get(void) {
CU_ASSERT_EQUAL(get, NULL);
// Add third entry with NULL key
- char * key3 = NULL;
- char * value3 = "value3";
hashMap_put(map, key3, value3);
get = hashMap_get(map, NULL);
@@ -130,46 +135,51 @@ void test_hashMap_get(void) {
}
void test_hashMap_containsKey(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char * neKey = "notExisting";
+ char * key3 = NULL;
+ char * value3 = "value3";
+
hashMap_clear(map, false, false);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
CU_ASSERT_TRUE(hashMap_containsKey(map, key));
CU_ASSERT_TRUE(hashMap_containsKey(map, key2));
- char * neKey = "notExisting";
CU_ASSERT_FALSE(hashMap_containsKey(map, neKey));
CU_ASSERT_FALSE(hashMap_containsKey(map, NULL));
// Add third entry with NULL key
- char * key3 = NULL;
- char * value3 = "value3";
hashMap_put(map, key3, value3);
CU_ASSERT_TRUE(hashMap_containsKey(map, key3));
}
void test_hashMap_getEntry(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char * neKey = "notExisting";
+ char * key3 = NULL;
+ char * value3 = "value3";
+ HASH_MAP_ENTRY entry;
+
hashMap_clear(map, false, false);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
-
- HASH_MAP_ENTRY entry = hashMap_getEntry(map, key);
+ entry = hashMap_getEntry(map, key);
CU_ASSERT_STRING_EQUAL(entry->key, key);
CU_ASSERT_STRING_EQUAL(entry->value, value);
@@ -177,7 +187,6 @@ void test_hashMap_getEntry(void) {
CU_ASSERT_STRING_EQUAL(entry->key, key2);
CU_ASSERT_STRING_EQUAL(entry->value, value2);
- char * neKey = "notExisting";
entry = hashMap_getEntry(map, neKey);
CU_ASSERT_EQUAL(entry, NULL);
@@ -185,8 +194,6 @@ void test_hashMap_getEntry(void) {
CU_ASSERT_EQUAL(entry, NULL);
// Add third entry with NULL key
- char * key3 = NULL;
- char * value3 = "value3";
hashMap_put(map, key3, value3);
entry = hashMap_getEntry(map, key3);
@@ -195,45 +202,51 @@ void test_hashMap_getEntry(void) {
}
void test_hashMap_put(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char * nkey2 = strdup("key2");
+ char * nvalue2 = "value3";
+ char * key3 = NULL;
+ char * value3 = "value3";
+ char * key4 = "key4";
+ char * value4 = NULL;
+ char * old;
+ char * get;
+
hashMap_clear(map, false, false);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
- char * get = hashMap_get(map, key);
+ get = hashMap_get(map, key);
CU_ASSERT_STRING_EQUAL(get, value);
get = hashMap_get(map, key2);
CU_ASSERT_STRING_EQUAL(get, value2);
- // Overwrite existing entry
- char * nkey2 = "key2";
- char * nvalue2 = "value3";
- char * old = (char *) hashMap_put(map, nkey2, nvalue2);
- CU_ASSERT_PTR_NOT_NULL_FATAL(old);
- CU_ASSERT_STRING_EQUAL(old, value2);
+ // Try to add an entry with the same key, since no explicit hash
function is used,
+ // this will not overwrite an existing entry.
+ old = (char *) hashMap_put(map, nkey2, nvalue2);
+ CU_ASSERT_PTR_NULL_FATAL(old);
+ // Retrieving the values will return the correct values
get = hashMap_get(map, key2);
- CU_ASSERT_STRING_EQUAL(get, nvalue2);
+ CU_ASSERT_STRING_EQUAL(get, value2);
+ get = hashMap_get(map, nkey2);
+ CU_ASSERT_STRING_EQUAL(get, nvalue2);
// Add third entry with NULL key
- char * key3 = NULL;
- char * value3 = "value3";
hashMap_put(map, key3, value3);
get = hashMap_get(map, key3);
CU_ASSERT_STRING_EQUAL(get, value3);
// Add fourth entry with NULL value
- char * key4 = "key4";
- char * value4 = NULL;
hashMap_put(map, key4, value4);
get = hashMap_get(map, key4);
@@ -241,23 +254,25 @@ void test_hashMap_put(void) {
}
void test_hashMap_resize(void) {
+ int i;
+ char * k;
+ char key[6];
+
hashMap_clear(map, false, false);
CU_ASSERT_EQUAL(map->size, 0);
CU_ASSERT_EQUAL(map->tablelength, 16);
CU_ASSERT_EQUAL(map->treshold, 12);
- int i;
for (i = 0; i < 12; i++) {
char key[6];
sprintf(key, "key%d", i);
- char * k = strdup(key);
+ k = strdup(key);
hashMap_put(map, k, k);
}
CU_ASSERT_EQUAL(map->size, 12);
CU_ASSERT_EQUAL(map->tablelength, 16);
CU_ASSERT_EQUAL(map->treshold, 12);
- char key[6];
sprintf(key, "key%d", i);
hashMap_put(map, strdup(key), strdup(key));
CU_ASSERT_EQUAL(map->size, 13);
@@ -266,20 +281,22 @@ void test_hashMap_resize(void) {
}
void test_hashMap_remove(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = NULL;
+ char * value2 = "value2";
+ char * removeKey;
+
hashMap_clear(map, false, false);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
// Add second entry with null key
- char * key2 = NULL;
- char * value2 = "value2";
hashMap_put(map, key2, value2);
// Remove unexisting entry for map
- char * removeKey = "unexisting";
+ removeKey = "unexisting";
hashMap_remove(map, removeKey);
CU_ASSERT_EQUAL(map->size, 2);
CU_ASSERT_FALSE(hashMap_isEmpty(map));
@@ -299,25 +316,29 @@ void test_hashMap_remove(void) {
}
void test_hashMap_removeMapping(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = NULL;
+ char * value2 = "value2";
+ HASH_MAP_ENTRY entry1;
+ HASH_MAP_ENTRY entry2;
+ HASH_MAP_ENTRY removed;
+
hashMap_clear(map, false, false);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
// Add second entry with null key
- char * key2 = NULL;
- char * value2 = "value2";
hashMap_put(map, key2, value2);
- HASH_MAP_ENTRY entry1 = hashMap_getEntry(map, key);
- HASH_MAP_ENTRY entry2 = hashMap_getEntry(map, key2);
+ entry1 = hashMap_getEntry(map, key);
+ entry2 = hashMap_getEntry(map, key2);
CU_ASSERT_PTR_NOT_NULL_FATAL(entry1);
CU_ASSERT_PTR_NOT_NULL_FATAL(entry2);
- HASH_MAP_ENTRY removed = hashMap_removeMapping(map, entry1);
+ removed = hashMap_removeMapping(map, entry1);
CU_ASSERT_PTR_EQUAL(entry1, removed);
CU_ASSERT_EQUAL(map->size, 1);
@@ -332,25 +353,26 @@ void test_hashMap_removeMapping(void) {
}
void test_hashMap_clear(void) {
- hashMap_clear(map, false, false);
- // Add one entry
char * key = "key";
char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char * key3 = NULL;
+ char * value3 = "value3";
+ char * key4 = "key4";
+ char * value4 = NULL;
+
+ hashMap_clear(map, false, false);
+ // Add one entry
hashMap_put(map, key, value);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
// Add third entry with NULL key
- char * key3 = NULL;
- char * value3 = "value3";
hashMap_put(map, key3, value3);
// Add fourth entry with NULL value
- char * key4 = "key4";
- char * value4 = NULL;
hashMap_put(map, key4, value4);
hashMap_clear(map, false, false);
@@ -358,48 +380,51 @@ void test_hashMap_clear(void) {
}
void test_hashMap_containsValue(void) {
+ char * key = "key";
+ char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char * neValue = "notExisting";
+ char * key3 = "key3";
+ char * value3 = NULL;
+
hashMap_clear(map, false, false);
// Add one entry
- char * key = "key";
- char * value = "value";
hashMap_put(map, key, value);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
CU_ASSERT_TRUE(hashMap_containsValue(map, value));
CU_ASSERT_TRUE(hashMap_containsValue(map, value2));
- char * neValue = "notExisting";
CU_ASSERT_FALSE(hashMap_containsValue(map, neValue));
CU_ASSERT_FALSE(hashMap_containsValue(map, NULL));
// Add third entry with NULL value
- char * key3 = "key3";
- char * value3 = NULL;
hashMap_put(map, key3, value3);
CU_ASSERT_TRUE(hashMap_containsValue(map, value3));
}
void test_hashMapValues_toArray(void) {
- hashMap_clear(map, false, false);
-
- // Add one entry
char * key = "key";
char * value = "value";
+ char * key2 = "key2";
+ char * value2 = "value2";
+ char **array;
+ int size;
+ HASH_MAP_VALUES values;
+
+ hashMap_clear(map, false, false);
+
+ // Add one entry
hashMap_put(map, key, value);
// Add second entry
- char * key2 = "key2";
- char * value2 = "value2";
hashMap_put(map, key2, value2);
- char **array;
- int size;
- HASH_MAP_VALUES values = hashMapValues_create(map);
+ values = hashMapValues_create(map);
hashMapValues_toArray(values, (void*)&array, &size);
CU_ASSERT_EQUAL(size, 2);
CU_ASSERT_TRUE(hashMapValues_contains(values, array[0]));
Modified: incubator/celix/trunk/celix_test/hash_map_test_hash.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/celix_test/hash_map_test_hash.c?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/celix_test/hash_map_test_hash.c (original)
+++ incubator/celix/trunk/celix_test/hash_map_test_hash.c Mon Jun 20 13:34:49
2011
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <string.h>
-#include "CUnit/Basic.h"
+#include <Basic.h>
#include "hash_map.h"
#include "hash_map_private.h"
Modified: incubator/celix/trunk/cmake/modules/FindCUnit.cmake
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/modules/FindCUnit.cmake?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/cmake/modules/FindCUnit.cmake (original)
+++ incubator/celix/trunk/cmake/modules/FindCUnit.cmake Mon Jun 20 13:34:49 2011
@@ -10,22 +10,24 @@
# CPPUNIT_LIBRARY, where to find the CppUnit library.
# CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug mode.
-include(FindCurses)
+if (NOT WIN32)
+ include(FindCurses)
+endif (NOT WIN32)
-FIND_PATH(CUNIT_INCLUDE_DIR CUnit/Basic.h
- /usr/local/include
- /usr/include
- /opt/local/include
+FIND_PATH(CUNIT_INCLUDE_DIR Basic.h
+ /usr/local/include/CUnit
+ /usr/include/CUnit
+ /opt/local/include/CUnit
)
# On unix system, debug and release have the same name
FIND_LIBRARY(CUNIT_LIBRARY cunit
- ${CUNIT_INCLUDE_DIR}/../lib
+ ${CUNIT_INCLUDE_DIR}/../../lib
/usr/local/lib
/usr/lib
)
FIND_LIBRARY(CUNIT_DEBUG_LIBRARY cunit
- ${CUNIT_INCLUDE_DIR}/../lib
+ ${CUNIT_INCLUDE_DIR}/../../lib
/usr/local/lib
/usr/lib
)
@@ -33,10 +35,20 @@ FIND_LIBRARY(CUNIT_DEBUG_LIBRARY cunit
IF(CUNIT_INCLUDE_DIR)
IF(CUNIT_LIBRARY)
SET(CUNIT_FOUND "YES")
- SET(CUNIT_LIBRARIES ${CUNIT_LIBRARY} ${CURSES_LIBRARY})
- SET(CUNIT_DEBUG_LIBRARIES ${CUNIT_DEBUG_LIBRARY} ${CURSES_DEBUG_LIBRARY})
+ if (WIN32)
+ SET(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
+ SET(CUNIT_DEBUG_LIBRARIES ${CUNIT_DEBUG_LIBRARY})
+ else (WIN32)
+ SET(CUNIT_LIBRARIES ${CUNIT_LIBRARY} ${CURSES_LIBRARY})
+ SET(CUNIT_DEBUG_LIBRARIES ${CUNIT_DEBUG_LIBRARY}
${CURSES_DEBUG_LIBRARY})
+ endif (WIN32)
ENDIF(CUNIT_LIBRARY)
IF(CUNIT_INCLUDE_DIR)
- SET(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR} ${CURSES_INCLUDE_DIR})
+ if (WIN32)
+ SET(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
+ else (WIN32)
+ MESSAGE(STATUS "Found CUNIT: ${CUNIT_INCLUDE_DIR}")
+ SET(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR}
${CURSES_INCLUDE_DIR})
+ endif (WIN32)
ENDIF(CUNIT_INCLUDE_DIR)
ENDIF(CUNIT_INCLUDE_DIR)
Modified: incubator/celix/trunk/utils/private/include/hash_map_private.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/include/hash_map_private.h?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/include/hash_map_private.h (original)
+++ incubator/celix/trunk/utils/private/include/hash_map_private.h Mon Jun 20
13:34:49 2011
@@ -26,14 +26,15 @@
#ifndef HASH_MAP_PRIVATE_H_
#define HASH_MAP_PRIVATE_H_
+#include "exports.h"
#include "hash_map.h"
-unsigned int hashMap_hashCode(void * toHash);
-int hashMap_equals(void * toCompare, void * compare);
+UTILS_EXPORT unsigned int hashMap_hashCode(void * toHash);
+UTILS_EXPORT int hashMap_equals(void * toCompare, void * compare);
void hashMap_resize(HASH_MAP map, int newCapacity);
void * hashMap_removeEntryForKey(HASH_MAP map, void * key);
-HASH_MAP_ENTRY hashMap_removeMapping(HASH_MAP map, HASH_MAP_ENTRY entry);
+UTILS_EXPORT HASH_MAP_ENTRY hashMap_removeMapping(HASH_MAP map, HASH_MAP_ENTRY
entry);
void hashMap_addEntry(HASH_MAP map, int hash, void * key, void * value, int
bucketIndex);
struct hashMapEntry {
Modified: incubator/celix/trunk/utils/private/src/hash_map.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/src/hash_map.c?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/hash_map.c (original)
+++ incubator/celix/trunk/utils/private/src/hash_map.c Mon Jun 20 13:34:49 2011
@@ -27,7 +27,6 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
-#include <stdint.h>
#include "hash_map.h"
#include "hash_map_private.h"
@@ -70,8 +69,7 @@ HASH_MAP hashMap_create(unsigned int (*k
int (*keyEquals)(void *, void *), int (*valueEquals)(void *,
void *)) {
HASH_MAP map = (HASH_MAP) malloc(sizeof(*map));
map->treshold = (int) (DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR);
- map->table = (HASH_MAP_ENTRY *) malloc(sizeof(HASH_MAP_ENTRY) *
DEFAULT_INITIAL_CAPACITY);
- memset(map->table, 0, DEFAULT_INITIAL_CAPACITY * sizeof(HASH_MAP_ENTRY
*));
+ map->table = (HASH_MAP_ENTRY *) calloc(DEFAULT_INITIAL_CAPACITY,
sizeof(HASH_MAP_ENTRY));
map->size = 0;
map->modificationCount = 0;
map->tablelength = DEFAULT_INITIAL_CAPACITY;
@@ -189,7 +187,7 @@ void hashMap_resize(HASH_MAP map, int ne
return;
}
- newTable = (HASH_MAP_ENTRY *) malloc(sizeof(HASH_MAP_ENTRY) *
newCapacity);
+ newTable = (HASH_MAP_ENTRY *) calloc(newCapacity,
sizeof(HASH_MAP_ENTRY));
for (j = 0; j < map->tablelength; j++) {
HASH_MAP_ENTRY entry = map->table[j];
Modified: incubator/celix/trunk/utils/public/include/array_list.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/utils/public/include/array_list.h?rev=1137628&r1=1137627&r2=1137628&view=diff
==============================================================================
--- incubator/celix/trunk/utils/public/include/array_list.h (original)
+++ incubator/celix/trunk/utils/public/include/array_list.h Mon Jun 20 13:34:49
2011
@@ -34,6 +34,7 @@ typedef struct arrayList * ARRAY_LIST;
typedef struct arrayListIterator * ARRAY_LIST_ITERATOR;
UTILS_EXPORT ARRAY_LIST arrayList_create(void);
+UTILS_EXPORT void arrayList_destroy(ARRAY_LIST list);
UTILS_EXPORT void arrayList_trimToSize(ARRAY_LIST list);
UTILS_EXPORT void arrayList_ensureCapacity(ARRAY_LIST list, int capacity);
UTILS_EXPORT unsigned int arrayList_size(ARRAY_LIST list);
@@ -45,6 +46,7 @@ UTILS_EXPORT void * arrayList_get(ARRAY_
UTILS_EXPORT void * arrayList_set(ARRAY_LIST list, unsigned int index, void *
element);
UTILS_EXPORT bool arrayList_add(ARRAY_LIST list, void * element);
UTILS_EXPORT int arrayList_addIndex(ARRAY_LIST list, unsigned int index, void
* element);
+UTILS_EXPORT bool arrayList_addAll(ARRAY_LIST list, ARRAY_LIST toAdd);
UTILS_EXPORT void * arrayList_remove(ARRAY_LIST list, unsigned int index);
UTILS_EXPORT bool arrayList_removeElement(ARRAY_LIST list, void * element);
UTILS_EXPORT void arrayList_clear(ARRAY_LIST list);