blob: 455d9ff8b63338fbbb19effde9c4f6804f20d910 (
plain)
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
|
#include "libnul.h"
static size_t
direct_hash (nul_const_ptr_t *ptr)
{
return (size_t)ptr;
}
static nul_bool_t
direct_equal (nul_const_ptr_t *ptr1, nul_const_ptr_t *ptr2)
{
return ptr1 == ptr2;
}
int
main ()
{
nul_hash_t *hash = nul_hash_new (direct_hash, direct_equal, NULL, NULL);
int i;
for (i = 0; i < 1234; ++i)
{
nul_hash_insert (hash, (nul_ptr_t)i, (nul_ptr_t)i);
}
for (i = 0; i < 1234; ++i)
{
g_assert (nul_hash_has_key (hash, (nul_ptr_t)i));
}
for (i = 0; i < 1234; ++i)
{
g_assert (nul_hash_remove (hash, (nul_ptr_t)i));
}
for (i = 0; i < 1234; ++i)
{
g_assert (!nul_hash_has_key (hash, (nul_ptr_t)i));
}
}
|