1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright © 2013 Daniel Buch
6 #include "alloc-util.h"
10 #include "string-util.h"
14 static bool arg_slow = false;
16 void test_hashmap_funcs(void);
18 static void test_hashmap_replace(void) {
20 char *val1, *val2, *val3, *val4, *val5, *r;
22 log_info("%s", __func__);
24 m = hashmap_new(&string_hash_ops);
26 val1 = strdup("val1");
28 val2 = strdup("val2");
30 val3 = strdup("val3");
32 val4 = strdup("val4");
34 val5 = strdup("val5");
37 hashmap_put(m, "key 1", val1);
38 hashmap_put(m, "key 2", val2);
39 hashmap_put(m, "key 3", val3);
40 hashmap_put(m, "key 4", val4);
42 hashmap_replace(m, "key 3", val1);
43 r = hashmap_get(m, "key 3");
44 assert_se(streq(r, "val1"));
46 hashmap_replace(m, "key 5", val5);
47 r = hashmap_get(m, "key 5");
48 assert_se(streq(r, "val5"));
58 static void test_hashmap_copy(void) {
60 char *val1, *val2, *val3, *val4, *r;
62 log_info("%s", __func__);
64 val1 = strdup("val1");
66 val2 = strdup("val2");
68 val3 = strdup("val3");
70 val4 = strdup("val4");
73 m = hashmap_new(&string_hash_ops);
75 hashmap_put(m, "key 1", val1);
76 hashmap_put(m, "key 2", val2);
77 hashmap_put(m, "key 3", val3);
78 hashmap_put(m, "key 4", val4);
80 copy = hashmap_copy(m);
82 r = hashmap_get(copy, "key 1");
83 assert_se(streq(r, "val1"));
84 r = hashmap_get(copy, "key 2");
85 assert_se(streq(r, "val2"));
86 r = hashmap_get(copy, "key 3");
87 assert_se(streq(r, "val3"));
88 r = hashmap_get(copy, "key 4");
89 assert_se(streq(r, "val4"));
91 hashmap_free_free(copy);
95 static void test_hashmap_get_strv(void) {
98 char *val1, *val2, *val3, *val4;
100 log_info("%s", __func__);
102 val1 = strdup("val1");
104 val2 = strdup("val2");
106 val3 = strdup("val3");
108 val4 = strdup("val4");
111 m = hashmap_new(&string_hash_ops);
113 hashmap_put(m, "key 1", val1);
114 hashmap_put(m, "key 2", val2);
115 hashmap_put(m, "key 3", val3);
116 hashmap_put(m, "key 4", val4);
118 strv = hashmap_get_strv(m);
121 strv = strv_sort(strv);
124 assert_se(streq(strv[0], "val1"));
125 assert_se(streq(strv[1], "val2"));
126 assert_se(streq(strv[2], "val3"));
127 assert_se(streq(strv[3], "val4"));
134 static void test_hashmap_move_one(void) {
136 char *val1, *val2, *val3, *val4, *r;
138 log_info("%s", __func__);
140 val1 = strdup("val1");
142 val2 = strdup("val2");
144 val3 = strdup("val3");
146 val4 = strdup("val4");
149 m = hashmap_new(&string_hash_ops);
150 n = hashmap_new(&string_hash_ops);
152 hashmap_put(m, "key 1", val1);
153 hashmap_put(m, "key 2", val2);
154 hashmap_put(m, "key 3", val3);
155 hashmap_put(m, "key 4", val4);
157 assert_se(hashmap_move_one(n, NULL, "key 3") == -ENOENT);
158 assert_se(hashmap_move_one(n, m, "key 5") == -ENOENT);
159 assert_se(hashmap_move_one(n, m, "key 3") == 0);
160 assert_se(hashmap_move_one(n, m, "key 4") == 0);
162 r = hashmap_get(n, "key 3");
163 assert_se(r && streq(r, "val3"));
164 r = hashmap_get(n, "key 4");
165 assert_se(r && streq(r, "val4"));
166 r = hashmap_get(m, "key 3");
169 assert_se(hashmap_move_one(n, m, "key 3") == -EEXIST);
171 hashmap_free_free(m);
172 hashmap_free_free(n);
175 static void test_hashmap_move(void) {
177 char *val1, *val2, *val3, *val4, *r;
179 log_info("%s", __func__);
181 val1 = strdup("val1");
183 val2 = strdup("val2");
185 val3 = strdup("val3");
187 val4 = strdup("val4");
190 m = hashmap_new(&string_hash_ops);
191 n = hashmap_new(&string_hash_ops);
193 hashmap_put(n, "key 1", strdup(val1));
194 hashmap_put(m, "key 1", val1);
195 hashmap_put(m, "key 2", val2);
196 hashmap_put(m, "key 3", val3);
197 hashmap_put(m, "key 4", val4);
199 assert_se(hashmap_move(n, NULL) == 0);
200 assert_se(hashmap_move(n, m) == 0);
202 assert_se(hashmap_size(m) == 1);
203 r = hashmap_get(m, "key 1");
204 assert_se(r && streq(r, "val1"));
206 r = hashmap_get(n, "key 1");
207 assert_se(r && streq(r, "val1"));
208 r = hashmap_get(n, "key 2");
209 assert_se(r && streq(r, "val2"));
210 r = hashmap_get(n, "key 3");
211 assert_se(r && streq(r, "val3"));
212 r = hashmap_get(n, "key 4");
213 assert_se(r && streq(r, "val4"));
215 hashmap_free_free(m);
216 hashmap_free_free(n);
219 static void test_hashmap_update(void) {
221 char *val1, *val2, *r;
223 log_info("%s", __func__);
225 m = hashmap_new(&string_hash_ops);
226 val1 = strdup("old_value");
228 val2 = strdup("new_value");
231 hashmap_put(m, "key 1", val1);
232 r = hashmap_get(m, "key 1");
233 assert_se(streq(r, "old_value"));
235 assert_se(hashmap_update(m, "key 2", val2) == -ENOENT);
236 r = hashmap_get(m, "key 1");
237 assert_se(streq(r, "old_value"));
239 assert_se(hashmap_update(m, "key 1", val2) == 0);
240 r = hashmap_get(m, "key 1");
241 assert_se(streq(r, "new_value"));
248 static void test_hashmap_put(void) {
250 int valid_hashmap_put;
251 void *val1 = (void*) "val 1";
252 void *val2 = (void*) "val 2";
253 _cleanup_free_ char* key1 = NULL;
255 log_info("%s", __func__);
257 assert_se(hashmap_ensure_allocated(&m, &string_hash_ops) >= 0);
260 valid_hashmap_put = hashmap_put(m, "key 1", val1);
261 assert_se(valid_hashmap_put == 1);
262 assert_se(hashmap_put(m, "key 1", val1) == 0);
263 assert_se(hashmap_put(m, "key 1", val2) == -EEXIST);
264 key1 = strdup("key 1");
265 assert_se(hashmap_put(m, key1, val1) == 0);
266 assert_se(hashmap_put(m, key1, val2) == -EEXIST);
271 static void test_hashmap_remove(void) {
272 _cleanup_hashmap_free_ Hashmap *m = NULL;
275 log_info("%s", __func__);
277 r = hashmap_remove(NULL, "key 1");
278 assert_se(r == NULL);
280 m = hashmap_new(&string_hash_ops);
283 r = hashmap_remove(m, "no such key");
284 assert_se(r == NULL);
286 hashmap_put(m, "key 1", (void*) "val 1");
287 hashmap_put(m, "key 2", (void*) "val 2");
289 r = hashmap_remove(m, "key 1");
290 assert_se(streq(r, "val 1"));
292 r = hashmap_get(m, "key 2");
293 assert_se(streq(r, "val 2"));
294 assert_se(!hashmap_get(m, "key 1"));
297 static void test_hashmap_remove2(void) {
298 _cleanup_hashmap_free_free_free_ Hashmap *m = NULL;
299 char key1[] = "key 1";
300 char key2[] = "key 2";
301 char val1[] = "val 1";
302 char val2[] = "val 2";
305 log_info("%s", __func__);
307 r = hashmap_remove2(NULL, "key 1", &r2);
308 assert_se(r == NULL);
310 m = hashmap_new(&string_hash_ops);
313 r = hashmap_remove2(m, "no such key", &r2);
314 assert_se(r == NULL);
316 hashmap_put(m, strdup(key1), strdup(val1));
317 hashmap_put(m, strdup(key2), strdup(val2));
319 r = hashmap_remove2(m, key1, &r2);
320 assert_se(streq(r, val1));
321 assert_se(streq(r2, key1));
325 r = hashmap_get(m, key2);
326 assert_se(streq(r, val2));
327 assert_se(!hashmap_get(m, key1));
330 static void test_hashmap_remove_value(void) {
331 _cleanup_hashmap_free_ Hashmap *m = NULL;
334 char val1[] = "val 1";
335 char val2[] = "val 2";
337 log_info("%s", __func__);
339 r = hashmap_remove_value(NULL, "key 1", val1);
340 assert_se(r == NULL);
342 m = hashmap_new(&string_hash_ops);
345 r = hashmap_remove_value(m, "key 1", val1);
346 assert_se(r == NULL);
348 hashmap_put(m, "key 1", val1);
349 hashmap_put(m, "key 2", val2);
351 r = hashmap_remove_value(m, "key 1", val1);
352 assert_se(streq(r, "val 1"));
354 r = hashmap_get(m, "key 2");
355 assert_se(streq(r, "val 2"));
356 assert_se(!hashmap_get(m, "key 1"));
358 r = hashmap_remove_value(m, "key 2", val1);
359 assert_se(r == NULL);
361 r = hashmap_get(m, "key 2");
362 assert_se(streq(r, "val 2"));
363 assert_se(!hashmap_get(m, "key 1"));
366 static void test_hashmap_remove_and_put(void) {
367 _cleanup_hashmap_free_ Hashmap *m = NULL;
371 log_info("%s", __func__);
373 m = hashmap_new(&string_hash_ops);
376 valid = hashmap_remove_and_put(m, "invalid key", "new key", NULL);
377 assert_se(valid == -ENOENT);
379 valid = hashmap_put(m, "key 1", (void*) (const char *) "val 1");
380 assert_se(valid == 1);
382 valid = hashmap_remove_and_put(NULL, "key 1", "key 2", (void*) (const char *) "val 2");
383 assert_se(valid == -ENOENT);
385 valid = hashmap_remove_and_put(m, "key 1", "key 2", (void*) (const char *) "val 2");
386 assert_se(valid == 0);
388 r = hashmap_get(m, "key 2");
389 assert_se(streq(r, "val 2"));
390 assert_se(!hashmap_get(m, "key 1"));
392 valid = hashmap_put(m, "key 3", (void*) (const char *) "val 3");
393 assert_se(valid == 1);
394 valid = hashmap_remove_and_put(m, "key 3", "key 2", (void*) (const char *) "val 2");
395 assert_se(valid == -EEXIST);
398 static void test_hashmap_remove_and_replace(void) {
399 _cleanup_hashmap_free_ Hashmap *m = NULL;
401 void *key1 = UINT_TO_PTR(1);
402 void *key2 = UINT_TO_PTR(2);
403 void *key3 = UINT_TO_PTR(3);
407 log_info("%s", __func__);
409 m = hashmap_new(&trivial_hash_ops);
412 valid = hashmap_remove_and_replace(m, key1, key2, NULL);
413 assert_se(valid == -ENOENT);
415 valid = hashmap_put(m, key1, key1);
416 assert_se(valid == 1);
418 valid = hashmap_remove_and_replace(NULL, key1, key2, key2);
419 assert_se(valid == -ENOENT);
421 valid = hashmap_remove_and_replace(m, key1, key2, key2);
422 assert_se(valid == 0);
424 r = hashmap_get(m, key2);
425 assert_se(r == key2);
426 assert_se(!hashmap_get(m, key1));
428 valid = hashmap_put(m, key3, key3);
429 assert_se(valid == 1);
430 valid = hashmap_remove_and_replace(m, key3, key2, key2);
431 assert_se(valid == 0);
432 r = hashmap_get(m, key2);
433 assert_se(r == key2);
434 assert_se(!hashmap_get(m, key3));
436 /* Repeat this test several times to increase the chance of hitting
437 * the less likely case in hashmap_remove_and_replace where it
438 * compensates for the backward shift. */
439 for (i = 0; i < 20; i++) {
442 for (j = 1; j < 7; j++)
443 hashmap_put(m, UINT_TO_PTR(10*i + j), UINT_TO_PTR(10*i + j));
444 valid = hashmap_remove_and_replace(m, UINT_TO_PTR(10*i + 1),
445 UINT_TO_PTR(10*i + 2),
446 UINT_TO_PTR(10*i + 2));
447 assert_se(valid == 0);
448 assert_se(!hashmap_get(m, UINT_TO_PTR(10*i + 1)));
449 for (j = 2; j < 7; j++) {
450 r = hashmap_get(m, UINT_TO_PTR(10*i + j));
451 assert_se(r == UINT_TO_PTR(10*i + j));
456 static void test_hashmap_ensure_allocated(void) {
460 log_info("%s", __func__);
462 m = hashmap_new(&string_hash_ops);
464 valid_hashmap = hashmap_ensure_allocated(&m, &string_hash_ops);
465 assert_se(valid_hashmap == 0);
471 static void test_hashmap_foreach_key(void) {
474 bool key_found[] = { false, false, false, false };
477 static const char key_table[] =
483 log_info("%s", __func__);
485 m = hashmap_new(&string_hash_ops);
487 NULSTR_FOREACH(key, key_table)
488 hashmap_put(m, key, (void*) (const char*) "my dummy val");
490 HASHMAP_FOREACH_KEY(s, key, m, i) {
492 if (!key_found[0] && streq(key, "key 1"))
494 else if (!key_found[1] && streq(key, "key 2"))
496 else if (!key_found[2] && streq(key, "key 3"))
498 else if (!key_found[3] && streq(key, "fail"))
503 assert_se(key_found[0] && key_found[1] && key_found[2] && !key_found[3]);
508 static void test_hashmap_foreach(void) {
511 bool value_found[] = { false, false, false, false };
512 char *val1, *val2, *val3, *val4, *s;
515 log_info("%s", __func__);
517 val1 = strdup("my val1");
519 val2 = strdup("my val2");
521 val3 = strdup("my val3");
523 val4 = strdup("my val4");
529 HASHMAP_FOREACH(s, m, i)
531 assert_se(count == 0);
533 m = hashmap_new(&string_hash_ops);
536 HASHMAP_FOREACH(s, m, i)
538 assert_se(count == 0);
540 hashmap_put(m, "Key 1", val1);
541 hashmap_put(m, "Key 2", val2);
542 hashmap_put(m, "Key 3", val3);
543 hashmap_put(m, "Key 4", val4);
545 HASHMAP_FOREACH(s, m, i) {
546 if (!value_found[0] && streq(s, val1))
547 value_found[0] = true;
548 else if (!value_found[1] && streq(s, val2))
549 value_found[1] = true;
550 else if (!value_found[2] && streq(s, val3))
551 value_found[2] = true;
552 else if (!value_found[3] && streq(s, val4))
553 value_found[3] = true;
557 assert_se(value_found[0] && value_found[1] && value_found[2] && value_found[3]);
559 hashmap_free_free(m);
562 static void test_hashmap_merge(void) {
565 char *val1, *val2, *val3, *val4, *r;
567 log_info("%s", __func__);
569 val1 = strdup("my val1");
571 val2 = strdup("my val2");
573 val3 = strdup("my val3");
575 val4 = strdup("my val4");
578 n = hashmap_new(&string_hash_ops);
579 m = hashmap_new(&string_hash_ops);
581 hashmap_put(m, "Key 1", val1);
582 hashmap_put(m, "Key 2", val2);
583 hashmap_put(n, "Key 3", val3);
584 hashmap_put(n, "Key 4", val4);
586 assert_se(hashmap_merge(m, n) == 0);
587 r = hashmap_get(m, "Key 3");
588 assert_se(r && streq(r, "my val3"));
589 r = hashmap_get(m, "Key 4");
590 assert_se(r && streq(r, "my val4"));
595 hashmap_free_free(m);
598 static void test_hashmap_contains(void) {
602 log_info("%s", __func__);
604 val1 = strdup("my val");
607 m = hashmap_new(&string_hash_ops);
609 assert_se(!hashmap_contains(m, "Key 1"));
610 hashmap_put(m, "Key 1", val1);
611 assert_se(hashmap_contains(m, "Key 1"));
612 assert_se(!hashmap_contains(m, "Key 2"));
614 assert_se(!hashmap_contains(NULL, "Key 1"));
617 hashmap_free_free(m);
620 static void test_hashmap_isempty(void) {
624 log_info("%s", __func__);
626 val1 = strdup("my val");
629 m = hashmap_new(&string_hash_ops);
631 assert_se(hashmap_isempty(m));
632 hashmap_put(m, "Key 1", val1);
633 assert_se(!hashmap_isempty(m));
636 hashmap_free_free(m);
639 static void test_hashmap_size(void) {
641 char *val1, *val2, *val3, *val4;
643 log_info("%s", __func__);
645 val1 = strdup("my val");
647 val2 = strdup("my val");
649 val3 = strdup("my val");
651 val4 = strdup("my val");
654 assert_se(hashmap_size(NULL) == 0);
655 assert_se(hashmap_buckets(NULL) == 0);
657 m = hashmap_new(&string_hash_ops);
659 hashmap_put(m, "Key 1", val1);
660 hashmap_put(m, "Key 2", val2);
661 hashmap_put(m, "Key 3", val3);
662 hashmap_put(m, "Key 4", val4);
665 assert_se(hashmap_size(m) == 4);
666 assert_se(hashmap_buckets(m) >= 4);
667 hashmap_free_free(m);
670 static void test_hashmap_get(void) {
675 log_info("%s", __func__);
677 val = strdup("my val");
680 r = hashmap_get(NULL, "Key 1");
681 assert_se(r == NULL);
683 m = hashmap_new(&string_hash_ops);
685 hashmap_put(m, "Key 1", val);
687 r = hashmap_get(m, "Key 1");
688 assert_se(streq(r, val));
690 r = hashmap_get(m, "no such key");
691 assert_se(r == NULL);
694 hashmap_free_free(m);
697 static void test_hashmap_get2(void) {
701 char key_orig[] = "Key 1";
704 log_info("%s", __func__);
706 val = strdup("my val");
709 key_copy = strdup(key_orig);
712 r = hashmap_get2(NULL, key_orig, &key_copy);
713 assert_se(r == NULL);
715 m = hashmap_new(&string_hash_ops);
717 hashmap_put(m, key_copy, val);
720 r = hashmap_get2(m, key_orig, &key_copy);
721 assert_se(streq(r, val));
722 assert_se(key_orig != key_copy);
723 assert_se(streq(key_orig, key_copy));
725 r = hashmap_get2(m, "no such key", NULL);
726 assert_se(r == NULL);
729 hashmap_free_free_free(m);
732 static void crippled_hashmap_func(const void *p, struct siphash *state) {
733 return trivial_hash_func(INT_TO_PTR(PTR_TO_INT(p) & 0xff), state);
736 static const struct hash_ops crippled_hashmap_ops = {
737 .hash = crippled_hashmap_func,
738 .compare = trivial_compare_func,
741 static void test_hashmap_many(void) {
746 const struct hash_ops *ops;
749 { .ops = NULL, .n_entries = arg_slow ? 1 << 20 : 240 },
750 { .ops = &crippled_hashmap_ops, .n_entries = arg_slow ? 1 << 14 : 140 },
753 log_info("%s (%s)", __func__, arg_slow ? "slow" : "fast");
755 for (j = 0; j < ELEMENTSOF(tests); j++) {
756 assert_se(h = hashmap_new(tests[j].ops));
758 for (i = 1; i < tests[j].n_entries*3; i+=3) {
759 assert_se(hashmap_put(h, UINT_TO_PTR(i), UINT_TO_PTR(i)) >= 0);
760 assert_se(PTR_TO_UINT(hashmap_get(h, UINT_TO_PTR(i))) == i);
763 for (i = 1; i < tests[j].n_entries*3; i++)
764 assert_se(hashmap_contains(h, UINT_TO_PTR(i)) == (i % 3 == 1));
766 log_info("%u <= %u * 0.8 = %g", hashmap_size(h), hashmap_buckets(h), hashmap_buckets(h) * 0.8);
768 assert_se(hashmap_size(h) <= hashmap_buckets(h) * 0.8);
769 assert_se(hashmap_size(h) == tests[j].n_entries);
771 while (!hashmap_isempty(h)) {
772 k = hashmap_first_key(h);
773 v = hashmap_remove(h, k);
781 static void test_hashmap_first(void) {
782 _cleanup_hashmap_free_ Hashmap *m = NULL;
784 log_info("%s", __func__);
786 m = hashmap_new(&string_hash_ops);
789 assert_se(!hashmap_first(m));
790 assert_se(hashmap_put(m, "key 1", (void*) "val 1") == 1);
791 assert_se(streq(hashmap_first(m), "val 1"));
792 assert_se(hashmap_put(m, "key 2", (void*) "val 2") == 1);
794 assert_se(streq(hashmap_first(m), "val 1"));
795 assert_se(hashmap_remove(m, "key 1"));
796 assert_se(streq(hashmap_first(m), "val 2"));
800 static void test_hashmap_first_key(void) {
801 _cleanup_hashmap_free_ Hashmap *m = NULL;
803 log_info("%s", __func__);
805 m = hashmap_new(&string_hash_ops);
808 assert_se(!hashmap_first_key(m));
809 assert_se(hashmap_put(m, "key 1", NULL) == 1);
810 assert_se(streq(hashmap_first_key(m), "key 1"));
811 assert_se(hashmap_put(m, "key 2", NULL) == 1);
813 assert_se(streq(hashmap_first_key(m), "key 1"));
814 assert_se(hashmap_remove(m, "key 1") == NULL);
815 assert_se(streq(hashmap_first_key(m), "key 2"));
819 static void test_hashmap_steal_first_key(void) {
820 _cleanup_hashmap_free_ Hashmap *m = NULL;
822 log_info("%s", __func__);
824 m = hashmap_new(&string_hash_ops);
827 assert_se(!hashmap_steal_first_key(m));
828 assert_se(hashmap_put(m, "key 1", NULL) == 1);
829 assert_se(streq(hashmap_steal_first_key(m), "key 1"));
831 assert_se(hashmap_isempty(m));
834 static void test_hashmap_steal_first(void) {
835 _cleanup_hashmap_free_ Hashmap *m = NULL;
839 log_info("%s", __func__);
841 m = hashmap_new(&string_hash_ops);
844 assert_se(hashmap_put(m, "key 1", (void*) "1") == 1);
845 assert_se(hashmap_put(m, "key 2", (void*) "22") == 1);
846 assert_se(hashmap_put(m, "key 3", (void*) "333") == 1);
848 while ((val = hashmap_steal_first(m)))
849 seen[strlen(val) - 1]++;
851 assert_se(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
853 assert_se(hashmap_isempty(m));
856 static void test_hashmap_clear_free_free(void) {
857 _cleanup_hashmap_free_ Hashmap *m = NULL;
859 log_info("%s", __func__);
861 m = hashmap_new(&string_hash_ops);
864 assert_se(hashmap_put(m, strdup("key 1"), NULL) == 1);
865 assert_se(hashmap_put(m, strdup("key 2"), NULL) == 1);
866 assert_se(hashmap_put(m, strdup("key 3"), NULL) == 1);
868 hashmap_clear_free_free(m);
869 assert_se(hashmap_isempty(m));
872 static void test_hashmap_reserve(void) {
873 _cleanup_hashmap_free_ Hashmap *m = NULL;
875 log_info("%s", __func__);
877 m = hashmap_new(&string_hash_ops);
879 assert_se(hashmap_reserve(m, 1) == 0);
880 assert_se(hashmap_buckets(m) < 1000);
881 assert_se(hashmap_reserve(m, 1000) == 0);
882 assert_se(hashmap_buckets(m) >= 1000);
883 assert_se(hashmap_isempty(m));
885 assert_se(hashmap_put(m, "key 1", (void*) "val 1") == 1);
887 assert_se(hashmap_reserve(m, UINT_MAX) == -ENOMEM);
888 assert_se(hashmap_reserve(m, UINT_MAX - 1) == -ENOMEM);
891 void test_hashmap_funcs(void) {
892 #if 0 /// UNNEEDED by elogind
896 log_parse_environment();
899 #if 0 /// UNNEEDED by elogind
900 r = getenv_bool("SYSTEMD_SLOW_TESTS");
901 arg_slow = r >= 0 ? r : SYSTEMD_SLOW_TESTS_DEFAULT;
905 test_hashmap_get_strv();
906 test_hashmap_move_one();
908 test_hashmap_replace();
909 test_hashmap_update();
911 test_hashmap_remove();
912 test_hashmap_remove2();
913 test_hashmap_remove_value();
914 test_hashmap_remove_and_put();
915 test_hashmap_remove_and_replace();
916 test_hashmap_ensure_allocated();
917 test_hashmap_foreach();
918 test_hashmap_foreach_key();
919 test_hashmap_contains();
920 test_hashmap_merge();
921 test_hashmap_isempty();
926 test_hashmap_first();
927 test_hashmap_first_key();
928 test_hashmap_steal_first_key();
929 test_hashmap_steal_first();
930 test_hashmap_clear_free_free();
931 test_hashmap_reserve();