1.1 --- a/test/map_tests.c Thu Oct 11 16:29:30 2012 +0200 1.2 +++ b/test/map_tests.c Fri Oct 12 10:54:55 2012 +0200 1.3 @@ -17,7 +17,8 @@ 1.4 UCX_TEST_IMPLEMENT(test_ucx_key) { 1.5 UcxKey key = ucx_key("This is a text.", 15); 1.6 UCX_TEST_BEGIN 1.7 - UCX_TEST_ASSERT(strncmp(key.data, "This is a text.", 15) == 0, "failed"); 1.8 + UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0, 1.9 + "failed"); 1.10 UCX_TEST_ASSERT(key.len == 15, "failed"); 1.11 UCX_TEST_ASSERT(key.hash == 1261186027, "hash failed"); 1.12 1.13 @@ -179,9 +180,9 @@ 1.14 } 1.15 1.16 void* test_ucx_map_store_load_encdec(void *value, void *data, size_t *size) { 1.17 - char *string = (char*) value; 1.18 + const char *string = (const char*) value; 1.19 size_t n = strlen(string); 1.20 - char *encoded = malloc(n+1); 1.21 + char *encoded = (char*) malloc(n+1); 1.22 for (int i = 0 ; i < n ; i++) { 1.23 encoded[i] = string[n-1-i]; 1.24 } 1.25 @@ -218,29 +219,29 @@ 1.26 test_ucx_map_store_load_encdec, NULL); 1.27 fclose(f); 1.28 1.29 - char *value; 1.30 + const char *value; 1.31 UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed"); 1.32 1.33 - value = ucx_map_cstr_get(map, "test"); 1.34 + value = (const char *) ucx_map_cstr_get(map, "test"); 1.35 UCX_TEST_ASSERT(value != NULL, "value not found for key: test"); 1.36 UCX_TEST_ASSERT(strcmp(value, "test") == 0, "value error for key: test"); 1.37 1.38 - value = ucx_map_cstr_get(map, "key"); 1.39 + value = (const char *) ucx_map_cstr_get(map, "key"); 1.40 UCX_TEST_ASSERT(value != NULL, "value not found for key: key"); 1.41 UCX_TEST_ASSERT(strcmp(value, "value") == 0, "value error for key: key"); 1.42 1.43 - value = ucx_map_cstr_get(map, "other.very.long.key"); 1.44 + value = (const char *) ucx_map_cstr_get(map, "other.very.long.key"); 1.45 UCX_TEST_ASSERT(value != NULL, 1.46 "value not found for key: other.very.long.key"); 1.47 UCX_TEST_ASSERT(strcmp(value, "value") == 0, 1.48 "value error for key: other.very.long.key"); 1.49 1.50 - value = ucx_map_cstr_get(map, "testkey"); 1.51 + value = (const char *) ucx_map_cstr_get(map, "testkey"); 1.52 UCX_TEST_ASSERT(value != NULL, "value not found for key: testkey"); 1.53 UCX_TEST_ASSERT(strcmp(value, "testvalue") == 0, 1.54 "value error for key: testkey"); 1.55 1.56 - value = ucx_map_cstr_get(map, "simple"); 1.57 + value = (const char *) ucx_map_cstr_get(map, "simple"); 1.58 UCX_TEST_ASSERT(value != NULL, "value not found for key: simple"); 1.59 UCX_TEST_ASSERT(strcmp(value, "not a key but an extremely long value " 1.60 "to test if the buffer extension works as designed") == 0, 1.61 @@ -281,10 +282,10 @@ 1.62 1.63 UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed"); 1.64 UcxMapIterator iter = ucx_map_iterator(map); 1.65 - char *value; size_t n; 1.66 + const char *value; size_t n; 1.67 UCX_MAP_FOREACH(value, iter) { 1.68 n = strlen(value); 1.69 - UCX_TEST_ASSERT(strncmp(pool->data[iter.index], value, n), 1.70 + UCX_TEST_ASSERT(strncmp((const char*) pool->data[iter.index], value, n), 1.71 "values of map does not match pooled values"); 1.72 } 1.73 1.74 @@ -302,9 +303,9 @@ 1.75 1.76 UcxMap *clone = ucx_map_clone(map, NULL, NULL); 1.77 1.78 - char *v1 = ucx_map_cstr_get(map, "key1"); 1.79 - char *v2 = ucx_map_cstr_get(map, "key2"); 1.80 - char *v3 = ucx_map_cstr_get(map, "key3"); 1.81 + const char *v1 = (const char *) ucx_map_cstr_get(map, "key1"); 1.82 + const char *v2 = (const char *) ucx_map_cstr_get(map, "key2"); 1.83 + const char *v3 = (const char *) ucx_map_cstr_get(map, "key3"); 1.84 1.85 UCX_TEST_BEGIN 1.86 1.87 @@ -312,9 +313,9 @@ 1.88 UCX_TEST_ASSERT(v2 != NULL, "failed key 2"); 1.89 UCX_TEST_ASSERT(v3 != NULL, "failed key 3"); 1.90 1.91 - char *c1 = ucx_map_cstr_get(clone, "key1"); 1.92 - char *c2 = ucx_map_cstr_get(clone, "key2"); 1.93 - char *c3 = ucx_map_cstr_get(clone, "key3"); 1.94 + const char *c1 = (const char *) ucx_map_cstr_get(clone, "key1"); 1.95 + const char *c2 = (const char *) ucx_map_cstr_get(clone, "key2"); 1.96 + const char *c3 = (const char *) ucx_map_cstr_get(clone, "key3"); 1.97 1.98 UCX_TEST_ASSERT(c1 != NULL, "failed key 1 (clone)"); 1.99 UCX_TEST_ASSERT(c2 != NULL, "failed key 2 (clone)"); 1.100 @@ -350,7 +351,7 @@ 1.101 UCX_TEST_ASSERT(map->size == 25, "new capacity shall be 2.5 * count"); 1.102 UCX_TEST_ASSERT(map->count == 10, "new map element count incorrect"); 1.103 for (int i = 0 ; i < 10 ; i++) { 1.104 - char *value = ucx_map_cstr_get(map, keys[i]); 1.105 + const char *value = (const char *) ucx_map_cstr_get(map, keys[i]); 1.106 UCX_TEST_ASSERT(value != NULL, "new map is missing old keys"); 1.107 UCX_TEST_ASSERT(strncmp(value, values[i], 6) == 0, 1.108 "new map contains incorrect values");