consequently used intptr_t in mpool tests

Thu, 31 May 2012 09:18:26 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 31 May 2012 09:18:26 +0200
changeset 32
c7af4ec56e19
parent 31
91ac86557290
child 33
9c219a62070d

consequently used intptr_t in mpool tests

test/map_tests.c file | annotate | diff | comparison | revisions
test/mpool_tests.c file | annotate | diff | comparison | revisions
     1.1 --- a/test/map_tests.c	Fri May 25 17:39:27 2012 +0200
     1.2 +++ b/test/map_tests.c	Thu May 31 09:18:26 2012 +0200
     1.3 @@ -69,6 +69,7 @@
     1.4  }
     1.5  
     1.6  UCX_TEST_BEGIN(test_ucx_map_get) {
     1.7 +    // TODO:
     1.8      UCX_TEST_END
     1.9  }
    1.10  
    1.11 @@ -79,24 +80,24 @@
    1.12      int v2 = 15;
    1.13      int v3 = 7;
    1.14      int v4 = 9;
    1.15 -    
    1.16 +
    1.17      ucx_map_cstr_put(map, "v1", &v1);
    1.18      ucx_map_cstr_put(map, "v2", &v2);
    1.19      ucx_map_cstr_put(map, "v3", &v3);
    1.20      ucx_map_cstr_put(map, "v4", &v4);
    1.21 -    
    1.22 +
    1.23      UcxMapIterator i = ucx_map_iterator(map);
    1.24      int check = 0;
    1.25      int hit = 0;
    1.26 -    
    1.27 +
    1.28      UCX_MAP_FOREACH(int*, v, map, i) {
    1.29          check += *v;
    1.30          hit++;
    1.31      }
    1.32 -    
    1.33 +
    1.34      UCX_TEST_ASSERT(hit == 4, "test1: wrong number of hits");
    1.35      UCX_TEST_ASSERT(check == v1+v2+v3+v4, "test1: wrong result");
    1.36 -            
    1.37 +
    1.38      ucx_map_free(map);
    1.39      
    1.40      map = ucx_map_new(1);
     2.1 --- a/test/mpool_tests.c	Fri May 25 17:39:27 2012 +0200
     2.2 +++ b/test/mpool_tests.c	Thu May 31 09:18:26 2012 +0200
     2.3 @@ -22,12 +22,13 @@
     2.4      
     2.5      UcxMempool *pool = ucx_mempool_new(1);
     2.6      
     2.7 -    int *test = (int*) ucx_mempool_malloc(pool, sizeof(int));
     2.8 +    intptr_t *test = (intptr_t*) ucx_mempool_malloc(pool, sizeof(intptr_t));
     2.9      
    2.10      UCX_TEST_ASSERT(pool->ndata == 1, "counter not incremented")
    2.11      UCX_TEST_ASSERT(pool->size == 1, "chcap called")
    2.12      
    2.13 -    int *pooladdr = (int*)((char*)pool->data[0] + sizeof(ucx_destructor));
    2.14 +    intptr_t *pooladdr =
    2.15 +            (intptr_t*)((char*)pool->data[0] + sizeof(ucx_destructor));
    2.16      *pooladdr = 5;
    2.17      
    2.18      UCX_TEST_ASSERT(*test == 5, "wrong pointer")
    2.19 @@ -42,12 +43,13 @@
    2.20      UcxMempool *pool = ucx_mempool_new(1);
    2.21      
    2.22      ucx_mempool_malloc(pool, sizeof(int));
    2.23 -    int *test = (int*) ucx_mempool_malloc(pool, sizeof(int));
    2.24 +    intptr_t *test = (intptr_t*) ucx_mempool_malloc(pool, sizeof(intptr_t));
    2.25      
    2.26      UCX_TEST_ASSERT(pool->ndata == 2, "counter not incremented")
    2.27      UCX_TEST_ASSERT(pool->size == 17, "chcap not called")
    2.28      
    2.29 -    int *pooladdr = (int*)((char*)pool->data[1] + sizeof(ucx_destructor));
    2.30 +    intptr_t *pooladdr =
    2.31 +            (intptr_t*)((char*)pool->data[1] + sizeof(ucx_destructor));
    2.32      *pooladdr = 5;
    2.33      
    2.34      UCX_TEST_ASSERT(*test == 5, "wrong pointer")
    2.35 @@ -61,7 +63,7 @@
    2.36      
    2.37      UcxMempool *pool = ucx_mempool_new(1);
    2.38      
    2.39 -    int *test = (int*) ucx_mempool_calloc(pool, 2, sizeof(int));
    2.40 +    intptr_t *test = (intptr_t*) ucx_mempool_calloc(pool, 2, sizeof(intptr_t));
    2.41      
    2.42      UCX_TEST_ASSERT(test != NULL, "no memory for test data")
    2.43      UCX_TEST_ASSERT(test[0] == 0 && test[1] == 0, "failed")
    2.44 @@ -80,10 +82,10 @@
    2.45      
    2.46      UcxMempool *pool = ucx_mempool_new(2);
    2.47      
    2.48 -    ucx_mempool_malloc(pool, sizeof(int));
    2.49 +    ucx_mempool_malloc(pool, sizeof(intptr_t));
    2.50      intptr_t *test = (intptr_t*) ucx_mempool_calloc(pool, 2, sizeof(intptr_t));
    2.51      
    2.52 -    int *cb = (intptr_t*) malloc(sizeof(intptr_t));
    2.53 +    intptr_t *cb = (intptr_t*) malloc(sizeof(intptr_t));
    2.54      UCX_TEST_ASSERT(cb != NULL && test != NULL, "no memory for test data")
    2.55      
    2.56      test[0] = 5; test[1] = (intptr_t) cb;
    2.57 @@ -138,7 +140,7 @@
    2.58      
    2.59      UcxMempool *pool = ucx_mempool_new(2);
    2.60      
    2.61 -    ucx_mempool_malloc(pool, sizeof(int));
    2.62 +    ucx_mempool_malloc(pool, sizeof(intptr_t));
    2.63      intptr_t *test = (intptr_t*) ucx_mempool_calloc(pool, 2, sizeof(intptr_t));
    2.64      
    2.65      intptr_t *cb = (intptr_t*) malloc(sizeof(intptr_t));

mercurial