40 struct cx_hash_map_s *hmap = (struct cx_hash_map_s *) map; |
40 struct cx_hash_map_s *hmap = (struct cx_hash_map_s *) map; |
41 CX_TEST_ASSERT(hmap->bucket_count > 0); |
41 CX_TEST_ASSERT(hmap->bucket_count > 0); |
42 for(size_t i = 0 ; i < hmap->bucket_count ; i++) { |
42 for(size_t i = 0 ; i < hmap->bucket_count ; i++) { |
43 CX_TEST_ASSERT(hmap->buckets[i] == NULL); |
43 CX_TEST_ASSERT(hmap->buckets[i] == NULL); |
44 } |
44 } |
45 CX_TEST_ASSERT(map->base.item_size == 1); |
45 CX_TEST_ASSERT(map->base.elem_size == 1); |
46 CX_TEST_ASSERT(map->base.size == 0); |
46 CX_TEST_ASSERT(map->base.size == 0); |
47 CX_TEST_ASSERT(map->base.allocator == allocator); |
47 CX_TEST_ASSERT(map->base.allocator == allocator); |
48 CX_TEST_ASSERT(!map->base.store_pointer); |
48 CX_TEST_ASSERT(!map->base.store_pointer); |
49 CX_TEST_ASSERT(map->base.cmpfunc == NULL); |
49 CX_TEST_ASSERT(map->base.cmpfunc == NULL); |
50 CX_TEST_ASSERT(map->base.simple_destructor == NULL); |
50 CX_TEST_ASSERT(map->base.simple_destructor == NULL); |
51 CX_TEST_ASSERT(map->base.advanced_destructor == NULL); |
51 CX_TEST_ASSERT(map->base.advanced_destructor == NULL); |
52 CX_TEST_ASSERT(map->base.destructor_data == NULL); |
52 CX_TEST_ASSERT(map->base.destructor_data == NULL); |
53 cxMapStorePointers(map); |
53 cxMapStorePointers(map); |
54 CX_TEST_ASSERT(map->base.store_pointer); |
54 CX_TEST_ASSERT(map->base.store_pointer); |
55 CX_TEST_ASSERT(map->base.item_size == sizeof(void *)); |
55 CX_TEST_ASSERT(map->base.elem_size == sizeof(void *)); |
56 cxMapStoreObjects(map); |
56 cxMapStoreObjects(map); |
57 CX_TEST_ASSERT(!map->base.store_pointer); |
57 CX_TEST_ASSERT(!map->base.store_pointer); |
58 |
58 |
59 cxMapDestroy(map); |
59 cxMapDestroy(map); |
60 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
60 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
74 CX_TEST_ASSERT(hmap->buckets[i] == NULL); |
74 CX_TEST_ASSERT(hmap->buckets[i] == NULL); |
75 } |
75 } |
76 CX_TEST_ASSERT(map->base.size == 0); |
76 CX_TEST_ASSERT(map->base.size == 0); |
77 CX_TEST_ASSERT(map->base.allocator == allocator); |
77 CX_TEST_ASSERT(map->base.allocator == allocator); |
78 CX_TEST_ASSERT(map->base.store_pointer); |
78 CX_TEST_ASSERT(map->base.store_pointer); |
79 CX_TEST_ASSERT(map->base.item_size == sizeof(void *)); |
79 CX_TEST_ASSERT(map->base.elem_size == sizeof(void *)); |
80 |
80 |
81 cxMapDestroy(map); |
81 cxMapDestroy(map); |
82 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
82 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
83 } |
83 } |
84 cx_testing_allocator_destroy(&talloc); |
84 cx_testing_allocator_destroy(&talloc); |
564 // verify value iterator |
564 // verify value iterator |
565 { |
565 { |
566 // by using that the values in our test data are unique strings |
566 // by using that the values in our test data are unique strings |
567 // we can re-use a similar approach as above |
567 // we can re-use a similar approach as above |
568 CxIterator valiter = cxMapIteratorValues(map); |
568 CxIterator valiter = cxMapIteratorValues(map); |
569 CX_TEST_ASSERT(valiter.elem_size == map->base.item_size); |
569 CX_TEST_ASSERT(valiter.elem_size == map->base.elem_size); |
570 CX_TEST_ASSERT(valiter.elem_count == map->base.size); |
570 CX_TEST_ASSERT(valiter.elem_count == map->base.size); |
571 char const** values = calloc(map->base.size, sizeof(char const*)); |
571 char const** values = calloc(map->base.size, sizeof(char const*)); |
572 cx_foreach(char const*, elem, valiter) { |
572 cx_foreach(char const*, elem, valiter) { |
573 values[valiter.index] = elem; |
573 values[valiter.index] = elem; |
574 } |
574 } |