-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_map_delete.c
49 lines (34 loc) · 1.12 KB
/
test_map_delete.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <core/structures/map.h>
#include "test.h"
#include <stdint.h>
#include <inttypes.h>
int main(int argc, char **argv)
{
BEGIN_TESTS();
struct core_map container;
int key_size = sizeof(void *);
int value_size = sizeof(size_t);
uint64_t i;
uint64_t element_count;
element_count = 100000;
core_map_init(&container, key_size, value_size);
for (i = 0; i < element_count; ++i) {
TEST_POINTER_EQUALS(core_map_get(&container, &i), NULL);
core_map_add(&container, &i);
TEST_POINTER_NOT_EQUALS(core_map_get(&container, &i), NULL);
/*
* Delete something once in a while
*/
if (i % 2 == 0) {
TEST_POINTER_NOT_EQUALS(core_map_get(&container, &i), NULL);
core_map_delete(&container, &i);
TEST_POINTER_EQUALS(core_map_get(&container, &i), NULL);
TEST_POINTER_EQUALS(core_map_get(&container, &i), NULL);
core_map_add(&container, &i);
TEST_POINTER_NOT_EQUALS(core_map_get(&container, &i), NULL);
}
}
core_map_destroy(&container);
END_TESTS();
return 0;
}