test/map_tests.c

changeset 46
48ca036d7d9c
parent 44
46356d74e873
child 48
621a4430c404
--- a/test/map_tests.c	Thu Oct 04 19:46:10 2012 +0200
+++ b/test/map_tests.c	Fri Oct 05 10:25:33 2012 +0200
@@ -141,6 +141,17 @@
     ucx_map_free(map);
 }
 
+void* test_ucx_map_store_load_encdec(void *value, void *data) {
+    char *string = (char*) value;
+    size_t n = strlen(string);
+    char *encoded = malloc(n+1);
+    for (int i = 0 ; i < n ; i++) {
+        encoded[i] = string[n-1-i];
+    }
+    encoded[n] = 0;
+    return encoded;
+}
+
 UCX_TEST_IMPLEMENT(test_ucx_map_store_load) {
     UcxMap *map = ucx_map_new(4);
 
@@ -155,14 +166,14 @@
     int r;
 
     fwrite(" # comment test\n", 1, 16, f);
-    r = ucx_map_store(map, f);
+    r = ucx_map_store_enc(map, f, test_ucx_map_store_load_encdec, NULL);
     fwrite("!discard this", 1, 13, f);
 
     fclose(f);
     ucx_map_free(map);
     map = ucx_map_new(1);
     f = fopen("test_ucx_map_store", "r");
-    r += ucx_map_load(map, f);
+    r += ucx_map_load_enc(map, f, test_ucx_map_store_load_encdec, NULL);
 
     UCX_TEST_BEGIN
     char *value;

mercurial