1 #ifdef HAVE_DIX_CONFIG_H
2 #include <dix-config.h>
12 print_xid(void* ptr
, void* v
)
19 print_int(void* ptr
, void* v
)
32 const int numKeys
= 420;
35 h
= ht_create(sizeof(XID
), sizeof(int), ht_resourceid_hash
, ht_resourceid_compare
, NULL
);
37 for (c
= 0; c
< numKeys
; ++c
) {
40 dest
= ht_add(h
, &id
);
46 printf("Distribution after insertion\n");
47 ht_dump_distribution(h
);
48 ht_dump_contents(h
, print_xid
, print_int
, NULL
);
50 for (c
= 0; c
< numKeys
; ++c
) {
52 int* v
= ht_find(h
, &id
);
57 printf("Key %d doesn't have expected value %d but has %d instead\n",
63 printf("Cannot find key %d\n", c
);
68 printf("%d keys inserted and found\n", c
);
70 for (c
= 0; c
< numKeys
; ++c
) {
75 printf("Distribution after deletion\n");
76 ht_dump_distribution(h
);
91 const int numKeys
= 420;
94 h
= ht_create(sizeof(XID
), 0, ht_resourceid_hash
, ht_resourceid_compare
, NULL
);
96 for (c
= 0; c
< numKeys
; ++c
) {
101 for (c
= 0; c
< numKeys
; ++c
) {
103 if (!ht_find(h
, &id
)) {
105 printf("Cannot find key %d\n", c
);
111 if (ht_find(h
, &id
)) {
113 printf("Could find a key that shouldn't be there\n");
120 printf("Test with empty keys OK\n");
122 printf("Test with empty keys FAILED\n");
132 HtGenericHashSetupRec hashSetup
= {
137 h
= ht_create(4, 0, ht_generic_hash
, ht_generic_compare
, &hashSetup
);
139 if (!ht_add(h
, "helo") ||
140 !ht_add(h
, "wrld")) {
141 printf("Could not insert keys\n");
144 if (!ht_find(h
, "helo") ||
145 !ht_find(h
, "wrld")) {
147 printf("Could not find inserted keys\n");
150 printf("Hash distribution with two strings\n");
151 ht_dump_distribution(h
);