tests/test_hash_map.c

changeset 1635
4983b6a34996
parent 1632
f74e4fc496a2
child 1638
14ae6a039af7
equal deleted inserted replaced
1634:006e076a8db7 1635:4983b6a34996
36 CX_TEST(test_hash_map_create) { 36 CX_TEST(test_hash_map_create) {
37 CxTestingAllocator talloc; 37 CxTestingAllocator talloc;
38 cx_testing_allocator_init(&talloc); 38 cx_testing_allocator_init(&talloc);
39 CxAllocator *allocator = &talloc.base; 39 CxAllocator *allocator = &talloc.base;
40 CX_TEST_DO { 40 CX_TEST_DO {
41 CxMap *map = cxHashMapCreate(allocator, 1, 0); 41 CxMap *map = cxHashMapCreate(allocator, sizeof(int), 0);
42 struct cx_hash_map_s *hmap = (struct cx_hash_map_s *) map; 42 struct cx_hash_map_s *hmap = (struct cx_hash_map_s *) map;
43 CX_TEST_ASSERT(hmap->bucket_count > 0); 43 CX_TEST_ASSERT(hmap->bucket_count > 0);
44 for(size_t i = 0 ; i < hmap->bucket_count ; i++) { 44 for(size_t i = 0 ; i < hmap->bucket_count ; i++) {
45 CX_TEST_ASSERT(hmap->buckets[i] == NULL); 45 CX_TEST_ASSERT(hmap->buckets[i] == NULL);
46 } 46 }
47 CX_TEST_ASSERT(map->collection.elem_size == 1); 47 CX_TEST_ASSERT(map->collection.elem_size == 4);
48 CX_TEST_ASSERT(map->collection.size == 0); 48 CX_TEST_ASSERT(map->collection.size == 0);
49 CX_TEST_ASSERT(map->collection.allocator == allocator); 49 CX_TEST_ASSERT(map->collection.allocator == allocator);
50 CX_TEST_ASSERT(!map->collection.store_pointer); 50 CX_TEST_ASSERT(!map->collection.store_pointer);
51 CX_TEST_ASSERT(map->collection.simple_cmp == NULL); 51 CX_TEST_ASSERT(map->collection.simple_cmp == NULL);
52 CX_TEST_ASSERT(map->collection.advanced_cmp == cx_ccmp_memcmp); 52 CX_TEST_ASSERT(map->collection.advanced_cmp != NULL);
53 CX_TEST_ASSERT(map->collection.cmp_data == &map->collection.elem_size); 53 CX_TEST_ASSERT((uintptr_t) map->collection.cmp_data == sizeof(int));
54 CX_TEST_ASSERT(map->collection.simple_destructor == NULL); 54 CX_TEST_ASSERT(map->collection.simple_destructor == NULL);
55 CX_TEST_ASSERT(map->collection.advanced_destructor == NULL); 55 CX_TEST_ASSERT(map->collection.advanced_destructor == NULL);
56 CX_TEST_ASSERT(map->collection.destructor_data == NULL); 56 CX_TEST_ASSERT(map->collection.destructor_data == NULL);
57 57
58 cxMapFree(map); 58 cxMapFree(map);

mercurial