test/map_tests.c

changeset 46
48ca036d7d9c
parent 44
46356d74e873
child 48
621a4430c404
     1.1 --- a/test/map_tests.c	Thu Oct 04 19:46:10 2012 +0200
     1.2 +++ b/test/map_tests.c	Fri Oct 05 10:25:33 2012 +0200
     1.3 @@ -141,6 +141,17 @@
     1.4      ucx_map_free(map);
     1.5  }
     1.6  
     1.7 +void* test_ucx_map_store_load_encdec(void *value, void *data) {
     1.8 +    char *string = (char*) value;
     1.9 +    size_t n = strlen(string);
    1.10 +    char *encoded = malloc(n+1);
    1.11 +    for (int i = 0 ; i < n ; i++) {
    1.12 +        encoded[i] = string[n-1-i];
    1.13 +    }
    1.14 +    encoded[n] = 0;
    1.15 +    return encoded;
    1.16 +}
    1.17 +
    1.18  UCX_TEST_IMPLEMENT(test_ucx_map_store_load) {
    1.19      UcxMap *map = ucx_map_new(4);
    1.20  
    1.21 @@ -155,14 +166,14 @@
    1.22      int r;
    1.23  
    1.24      fwrite(" # comment test\n", 1, 16, f);
    1.25 -    r = ucx_map_store(map, f);
    1.26 +    r = ucx_map_store_enc(map, f, test_ucx_map_store_load_encdec, NULL);
    1.27      fwrite("!discard this", 1, 13, f);
    1.28  
    1.29      fclose(f);
    1.30      ucx_map_free(map);
    1.31      map = ucx_map_new(1);
    1.32      f = fopen("test_ucx_map_store", "r");
    1.33 -    r += ucx_map_load(map, f);
    1.34 +    r += ucx_map_load_enc(map, f, test_ucx_map_store_load_encdec, NULL);
    1.35  
    1.36      UCX_TEST_BEGIN
    1.37      char *value;

mercurial