Line data Source code
1 : /* GENERATED FILE */
2 : #define ORDERED
3 : /* SPDX-License-Identifier: LGPL-2.1+ */
4 :
5 : #include "alloc-util.h"
6 : #include "hashmap.h"
7 : #include "log.h"
8 : #include "nulstr-util.h"
9 : #include "stdio-util.h"
10 : #include "string-util.h"
11 : #include "strv.h"
12 : #include "time-util.h"
13 : #include "tests.h"
14 :
15 : void test_ordered_hashmap_funcs(void);
16 :
17 1 : static void test_ordered_hashmap_replace(void) {
18 : OrderedHashmap *m;
19 : char *val1, *val2, *val3, *val4, *val5, *r;
20 :
21 1 : log_info("/* %s */", __func__);
22 :
23 1 : m = ordered_hashmap_new(&string_hash_ops);
24 :
25 1 : val1 = strdup("val1");
26 1 : assert_se(val1);
27 1 : val2 = strdup("val2");
28 1 : assert_se(val2);
29 1 : val3 = strdup("val3");
30 1 : assert_se(val3);
31 1 : val4 = strdup("val4");
32 1 : assert_se(val4);
33 1 : val5 = strdup("val5");
34 1 : assert_se(val5);
35 :
36 1 : ordered_hashmap_put(m, "key 1", val1);
37 1 : ordered_hashmap_put(m, "key 2", val2);
38 1 : ordered_hashmap_put(m, "key 3", val3);
39 1 : ordered_hashmap_put(m, "key 4", val4);
40 :
41 1 : ordered_hashmap_replace(m, "key 3", val1);
42 1 : r = ordered_hashmap_get(m, "key 3");
43 1 : assert_se(streq(r, "val1"));
44 :
45 1 : ordered_hashmap_replace(m, "key 5", val5);
46 1 : r = ordered_hashmap_get(m, "key 5");
47 1 : assert_se(streq(r, "val5"));
48 :
49 1 : free(val1);
50 1 : free(val2);
51 1 : free(val3);
52 1 : free(val4);
53 1 : free(val5);
54 1 : ordered_hashmap_free(m);
55 1 : }
56 :
57 1 : static void test_ordered_hashmap_copy(void) {
58 : OrderedHashmap *m, *copy;
59 : char *val1, *val2, *val3, *val4, *r;
60 :
61 1 : log_info("/* %s */", __func__);
62 :
63 1 : val1 = strdup("val1");
64 1 : assert_se(val1);
65 1 : val2 = strdup("val2");
66 1 : assert_se(val2);
67 1 : val3 = strdup("val3");
68 1 : assert_se(val3);
69 1 : val4 = strdup("val4");
70 1 : assert_se(val4);
71 :
72 1 : m = ordered_hashmap_new(&string_hash_ops);
73 :
74 1 : ordered_hashmap_put(m, "key 1", val1);
75 1 : ordered_hashmap_put(m, "key 2", val2);
76 1 : ordered_hashmap_put(m, "key 3", val3);
77 1 : ordered_hashmap_put(m, "key 4", val4);
78 :
79 1 : copy = ordered_hashmap_copy(m);
80 :
81 1 : r = ordered_hashmap_get(copy, "key 1");
82 1 : assert_se(streq(r, "val1"));
83 1 : r = ordered_hashmap_get(copy, "key 2");
84 1 : assert_se(streq(r, "val2"));
85 1 : r = ordered_hashmap_get(copy, "key 3");
86 1 : assert_se(streq(r, "val3"));
87 1 : r = ordered_hashmap_get(copy, "key 4");
88 1 : assert_se(streq(r, "val4"));
89 :
90 1 : ordered_hashmap_free_free(copy);
91 1 : ordered_hashmap_free(m);
92 1 : }
93 :
94 1 : static void test_ordered_hashmap_get_strv(void) {
95 : OrderedHashmap *m;
96 : char **strv;
97 : char *val1, *val2, *val3, *val4;
98 :
99 1 : log_info("/* %s */", __func__);
100 :
101 1 : val1 = strdup("val1");
102 1 : assert_se(val1);
103 1 : val2 = strdup("val2");
104 1 : assert_se(val2);
105 1 : val3 = strdup("val3");
106 1 : assert_se(val3);
107 1 : val4 = strdup("val4");
108 1 : assert_se(val4);
109 :
110 1 : m = ordered_hashmap_new(&string_hash_ops);
111 :
112 1 : ordered_hashmap_put(m, "key 1", val1);
113 1 : ordered_hashmap_put(m, "key 2", val2);
114 1 : ordered_hashmap_put(m, "key 3", val3);
115 1 : ordered_hashmap_put(m, "key 4", val4);
116 :
117 1 : strv = ordered_hashmap_get_strv(m);
118 :
119 : #ifndef ORDERED
120 : strv = strv_sort(strv);
121 : #endif
122 :
123 1 : assert_se(streq(strv[0], "val1"));
124 1 : assert_se(streq(strv[1], "val2"));
125 1 : assert_se(streq(strv[2], "val3"));
126 1 : assert_se(streq(strv[3], "val4"));
127 :
128 1 : strv_free(strv);
129 :
130 1 : ordered_hashmap_free(m);
131 1 : }
132 :
133 1 : static void test_ordered_hashmap_move_one(void) {
134 : OrderedHashmap *m, *n;
135 : char *val1, *val2, *val3, *val4, *r;
136 :
137 1 : log_info("/* %s */", __func__);
138 :
139 1 : val1 = strdup("val1");
140 1 : assert_se(val1);
141 1 : val2 = strdup("val2");
142 1 : assert_se(val2);
143 1 : val3 = strdup("val3");
144 1 : assert_se(val3);
145 1 : val4 = strdup("val4");
146 1 : assert_se(val4);
147 :
148 1 : m = ordered_hashmap_new(&string_hash_ops);
149 1 : n = ordered_hashmap_new(&string_hash_ops);
150 :
151 1 : ordered_hashmap_put(m, "key 1", val1);
152 1 : ordered_hashmap_put(m, "key 2", val2);
153 1 : ordered_hashmap_put(m, "key 3", val3);
154 1 : ordered_hashmap_put(m, "key 4", val4);
155 :
156 1 : assert_se(ordered_hashmap_move_one(n, NULL, "key 3") == -ENOENT);
157 1 : assert_se(ordered_hashmap_move_one(n, m, "key 5") == -ENOENT);
158 1 : assert_se(ordered_hashmap_move_one(n, m, "key 3") == 0);
159 1 : assert_se(ordered_hashmap_move_one(n, m, "key 4") == 0);
160 :
161 1 : r = ordered_hashmap_get(n, "key 3");
162 1 : assert_se(r && streq(r, "val3"));
163 1 : r = ordered_hashmap_get(n, "key 4");
164 1 : assert_se(r && streq(r, "val4"));
165 1 : r = ordered_hashmap_get(m, "key 3");
166 1 : assert_se(!r);
167 :
168 1 : assert_se(ordered_hashmap_move_one(n, m, "key 3") == -EEXIST);
169 :
170 1 : ordered_hashmap_free_free(m);
171 1 : ordered_hashmap_free_free(n);
172 1 : }
173 :
174 1 : static void test_ordered_hashmap_move(void) {
175 : OrderedHashmap *m, *n;
176 : char *val1, *val2, *val3, *val4, *r;
177 :
178 1 : log_info("/* %s */", __func__);
179 :
180 1 : val1 = strdup("val1");
181 1 : assert_se(val1);
182 1 : val2 = strdup("val2");
183 1 : assert_se(val2);
184 1 : val3 = strdup("val3");
185 1 : assert_se(val3);
186 1 : val4 = strdup("val4");
187 1 : assert_se(val4);
188 :
189 1 : m = ordered_hashmap_new(&string_hash_ops);
190 1 : n = ordered_hashmap_new(&string_hash_ops);
191 :
192 1 : ordered_hashmap_put(n, "key 1", strdup(val1));
193 1 : ordered_hashmap_put(m, "key 1", val1);
194 1 : ordered_hashmap_put(m, "key 2", val2);
195 1 : ordered_hashmap_put(m, "key 3", val3);
196 1 : ordered_hashmap_put(m, "key 4", val4);
197 :
198 1 : assert_se(ordered_hashmap_move(n, NULL) == 0);
199 1 : assert_se(ordered_hashmap_move(n, m) == 0);
200 :
201 1 : assert_se(ordered_hashmap_size(m) == 1);
202 1 : r = ordered_hashmap_get(m, "key 1");
203 1 : assert_se(r && streq(r, "val1"));
204 :
205 1 : r = ordered_hashmap_get(n, "key 1");
206 1 : assert_se(r && streq(r, "val1"));
207 1 : r = ordered_hashmap_get(n, "key 2");
208 1 : assert_se(r && streq(r, "val2"));
209 1 : r = ordered_hashmap_get(n, "key 3");
210 1 : assert_se(r && streq(r, "val3"));
211 1 : r = ordered_hashmap_get(n, "key 4");
212 1 : assert_se(r && streq(r, "val4"));
213 :
214 1 : ordered_hashmap_free_free(m);
215 1 : ordered_hashmap_free_free(n);
216 1 : }
217 :
218 1 : static void test_ordered_hashmap_update(void) {
219 : OrderedHashmap *m;
220 : char *val1, *val2, *r;
221 :
222 1 : log_info("/* %s */", __func__);
223 :
224 1 : m = ordered_hashmap_new(&string_hash_ops);
225 1 : val1 = strdup("old_value");
226 1 : assert_se(val1);
227 1 : val2 = strdup("new_value");
228 1 : assert_se(val2);
229 :
230 1 : ordered_hashmap_put(m, "key 1", val1);
231 1 : r = ordered_hashmap_get(m, "key 1");
232 1 : assert_se(streq(r, "old_value"));
233 :
234 1 : assert_se(ordered_hashmap_update(m, "key 2", val2) == -ENOENT);
235 1 : r = ordered_hashmap_get(m, "key 1");
236 1 : assert_se(streq(r, "old_value"));
237 :
238 1 : assert_se(ordered_hashmap_update(m, "key 1", val2) == 0);
239 1 : r = ordered_hashmap_get(m, "key 1");
240 1 : assert_se(streq(r, "new_value"));
241 :
242 1 : free(val1);
243 1 : free(val2);
244 1 : ordered_hashmap_free(m);
245 1 : }
246 :
247 1 : static void test_ordered_hashmap_put(void) {
248 1 : OrderedHashmap *m = NULL;
249 : int valid_ordered_hashmap_put;
250 1 : void *val1 = (void*) "val 1";
251 1 : void *val2 = (void*) "val 2";
252 1 : _cleanup_free_ char* key1 = NULL;
253 :
254 1 : log_info("/* %s */", __func__);
255 :
256 1 : assert_se(ordered_hashmap_ensure_allocated(&m, &string_hash_ops) >= 0);
257 1 : assert_se(m);
258 :
259 1 : valid_ordered_hashmap_put = ordered_hashmap_put(m, "key 1", val1);
260 1 : assert_se(valid_ordered_hashmap_put == 1);
261 1 : assert_se(ordered_hashmap_put(m, "key 1", val1) == 0);
262 1 : assert_se(ordered_hashmap_put(m, "key 1", val2) == -EEXIST);
263 1 : key1 = strdup("key 1");
264 1 : assert_se(ordered_hashmap_put(m, key1, val1) == 0);
265 1 : assert_se(ordered_hashmap_put(m, key1, val2) == -EEXIST);
266 :
267 1 : ordered_hashmap_free(m);
268 1 : }
269 :
270 1 : static void test_ordered_hashmap_remove(void) {
271 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
272 : char *r;
273 :
274 1 : log_info("/* %s */", __func__);
275 :
276 1 : r = ordered_hashmap_remove(NULL, "key 1");
277 1 : assert_se(r == NULL);
278 :
279 1 : m = ordered_hashmap_new(&string_hash_ops);
280 1 : assert_se(m);
281 :
282 1 : r = ordered_hashmap_remove(m, "no such key");
283 1 : assert_se(r == NULL);
284 :
285 1 : ordered_hashmap_put(m, "key 1", (void*) "val 1");
286 1 : ordered_hashmap_put(m, "key 2", (void*) "val 2");
287 :
288 1 : r = ordered_hashmap_remove(m, "key 1");
289 1 : assert_se(streq(r, "val 1"));
290 :
291 1 : r = ordered_hashmap_get(m, "key 2");
292 1 : assert_se(streq(r, "val 2"));
293 1 : assert_se(!ordered_hashmap_get(m, "key 1"));
294 1 : }
295 :
296 1 : static void test_ordered_hashmap_remove2(void) {
297 1 : _cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *m = NULL;
298 1 : char key1[] = "key 1";
299 1 : char key2[] = "key 2";
300 1 : char val1[] = "val 1";
301 1 : char val2[] = "val 2";
302 : void *r, *r2;
303 :
304 1 : log_info("/* %s */", __func__);
305 :
306 1 : r = ordered_hashmap_remove2(NULL, "key 1", &r2);
307 1 : assert_se(r == NULL);
308 :
309 1 : m = ordered_hashmap_new(&string_hash_ops);
310 1 : assert_se(m);
311 :
312 1 : r = ordered_hashmap_remove2(m, "no such key", &r2);
313 1 : assert_se(r == NULL);
314 :
315 1 : ordered_hashmap_put(m, strdup(key1), strdup(val1));
316 1 : ordered_hashmap_put(m, strdup(key2), strdup(val2));
317 :
318 1 : r = ordered_hashmap_remove2(m, key1, &r2);
319 1 : assert_se(streq(r, val1));
320 1 : assert_se(streq(r2, key1));
321 1 : free(r);
322 1 : free(r2);
323 :
324 1 : r = ordered_hashmap_get(m, key2);
325 1 : assert_se(streq(r, val2));
326 1 : assert_se(!ordered_hashmap_get(m, key1));
327 1 : }
328 :
329 1 : static void test_ordered_hashmap_remove_value(void) {
330 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
331 : char *r;
332 :
333 1 : char val1[] = "val 1";
334 1 : char val2[] = "val 2";
335 :
336 1 : log_info("/* %s */", __func__);
337 :
338 1 : r = ordered_hashmap_remove_value(NULL, "key 1", val1);
339 1 : assert_se(r == NULL);
340 :
341 1 : m = ordered_hashmap_new(&string_hash_ops);
342 1 : assert_se(m);
343 :
344 1 : r = ordered_hashmap_remove_value(m, "key 1", val1);
345 1 : assert_se(r == NULL);
346 :
347 1 : ordered_hashmap_put(m, "key 1", val1);
348 1 : ordered_hashmap_put(m, "key 2", val2);
349 :
350 1 : r = ordered_hashmap_remove_value(m, "key 1", val1);
351 1 : assert_se(streq(r, "val 1"));
352 :
353 1 : r = ordered_hashmap_get(m, "key 2");
354 1 : assert_se(streq(r, "val 2"));
355 1 : assert_se(!ordered_hashmap_get(m, "key 1"));
356 :
357 1 : r = ordered_hashmap_remove_value(m, "key 2", val1);
358 1 : assert_se(r == NULL);
359 :
360 1 : r = ordered_hashmap_get(m, "key 2");
361 1 : assert_se(streq(r, "val 2"));
362 1 : assert_se(!ordered_hashmap_get(m, "key 1"));
363 1 : }
364 :
365 1 : static void test_ordered_hashmap_remove_and_put(void) {
366 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
367 : int valid;
368 : char *r;
369 :
370 1 : log_info("/* %s */", __func__);
371 :
372 1 : m = ordered_hashmap_new(&string_hash_ops);
373 1 : assert_se(m);
374 :
375 1 : valid = ordered_hashmap_remove_and_put(m, "invalid key", "new key", NULL);
376 1 : assert_se(valid == -ENOENT);
377 :
378 1 : valid = ordered_hashmap_put(m, "key 1", (void*) (const char *) "val 1");
379 1 : assert_se(valid == 1);
380 :
381 1 : valid = ordered_hashmap_remove_and_put(NULL, "key 1", "key 2", (void*) (const char *) "val 2");
382 1 : assert_se(valid == -ENOENT);
383 :
384 1 : valid = ordered_hashmap_remove_and_put(m, "key 1", "key 2", (void*) (const char *) "val 2");
385 1 : assert_se(valid == 0);
386 :
387 1 : r = ordered_hashmap_get(m, "key 2");
388 1 : assert_se(streq(r, "val 2"));
389 1 : assert_se(!ordered_hashmap_get(m, "key 1"));
390 :
391 1 : valid = ordered_hashmap_put(m, "key 3", (void*) (const char *) "val 3");
392 1 : assert_se(valid == 1);
393 1 : valid = ordered_hashmap_remove_and_put(m, "key 3", "key 2", (void*) (const char *) "val 2");
394 1 : assert_se(valid == -EEXIST);
395 1 : }
396 :
397 1 : static void test_ordered_hashmap_remove_and_replace(void) {
398 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
399 : int valid;
400 1 : void *key1 = UINT_TO_PTR(1);
401 1 : void *key2 = UINT_TO_PTR(2);
402 1 : void *key3 = UINT_TO_PTR(3);
403 : void *r;
404 : int i, j;
405 :
406 1 : log_info("/* %s */", __func__);
407 :
408 1 : m = ordered_hashmap_new(&trivial_hash_ops);
409 1 : assert_se(m);
410 :
411 1 : valid = ordered_hashmap_remove_and_replace(m, key1, key2, NULL);
412 1 : assert_se(valid == -ENOENT);
413 :
414 1 : valid = ordered_hashmap_put(m, key1, key1);
415 1 : assert_se(valid == 1);
416 :
417 1 : valid = ordered_hashmap_remove_and_replace(NULL, key1, key2, key2);
418 1 : assert_se(valid == -ENOENT);
419 :
420 1 : valid = ordered_hashmap_remove_and_replace(m, key1, key2, key2);
421 1 : assert_se(valid == 0);
422 :
423 1 : r = ordered_hashmap_get(m, key2);
424 1 : assert_se(r == key2);
425 1 : assert_se(!ordered_hashmap_get(m, key1));
426 :
427 1 : valid = ordered_hashmap_put(m, key3, key3);
428 1 : assert_se(valid == 1);
429 1 : valid = ordered_hashmap_remove_and_replace(m, key3, key2, key2);
430 1 : assert_se(valid == 0);
431 1 : r = ordered_hashmap_get(m, key2);
432 1 : assert_se(r == key2);
433 1 : assert_se(!ordered_hashmap_get(m, key3));
434 :
435 : /* Repeat this test several times to increase the chance of hitting
436 : * the less likely case in ordered_hashmap_remove_and_replace where it
437 : * compensates for the backward shift. */
438 21 : for (i = 0; i < 20; i++) {
439 20 : ordered_hashmap_clear(m);
440 :
441 140 : for (j = 1; j < 7; j++)
442 120 : ordered_hashmap_put(m, UINT_TO_PTR(10*i + j), UINT_TO_PTR(10*i + j));
443 40 : valid = ordered_hashmap_remove_and_replace(m, UINT_TO_PTR(10*i + 1),
444 20 : UINT_TO_PTR(10*i + 2),
445 20 : UINT_TO_PTR(10*i + 2));
446 20 : assert_se(valid == 0);
447 20 : assert_se(!ordered_hashmap_get(m, UINT_TO_PTR(10*i + 1)));
448 120 : for (j = 2; j < 7; j++) {
449 100 : r = ordered_hashmap_get(m, UINT_TO_PTR(10*i + j));
450 100 : assert_se(r == UINT_TO_PTR(10*i + j));
451 : }
452 : }
453 1 : }
454 :
455 1 : static void test_ordered_hashmap_ensure_allocated(void) {
456 : OrderedHashmap *m;
457 : int valid_ordered_hashmap;
458 :
459 1 : log_info("/* %s */", __func__);
460 :
461 1 : m = ordered_hashmap_new(&string_hash_ops);
462 :
463 1 : valid_ordered_hashmap = ordered_hashmap_ensure_allocated(&m, &string_hash_ops);
464 1 : assert_se(valid_ordered_hashmap == 0);
465 :
466 1 : assert_se(m);
467 1 : ordered_hashmap_free(m);
468 1 : }
469 :
470 1 : static void test_ordered_hashmap_foreach_key(void) {
471 : OrderedHashmap *m;
472 : Iterator i;
473 1 : bool key_found[] = { false, false, false, false };
474 : const char *s;
475 : const char *key;
476 : static const char key_table[] =
477 : "key 1\0"
478 : "key 2\0"
479 : "key 3\0"
480 : "key 4\0";
481 :
482 1 : log_info("/* %s */", __func__);
483 :
484 1 : m = ordered_hashmap_new(&string_hash_ops);
485 :
486 5 : NULSTR_FOREACH(key, key_table)
487 4 : ordered_hashmap_put(m, key, (void*) (const char*) "my dummy val");
488 :
489 5 : ORDERED_HASHMAP_FOREACH_KEY(s, key, m, i) {
490 4 : assert(s);
491 4 : if (!key_found[0] && streq(key, "key 1"))
492 1 : key_found[0] = true;
493 3 : else if (!key_found[1] && streq(key, "key 2"))
494 1 : key_found[1] = true;
495 2 : else if (!key_found[2] && streq(key, "key 3"))
496 1 : key_found[2] = true;
497 1 : else if (!key_found[3] && streq(key, "fail"))
498 0 : key_found[3] = true;
499 : }
500 :
501 1 : assert_se(m);
502 1 : assert_se(key_found[0] && key_found[1] && key_found[2] && !key_found[3]);
503 :
504 1 : ordered_hashmap_free(m);
505 1 : }
506 :
507 1 : static void test_ordered_hashmap_foreach(void) {
508 : OrderedHashmap *m;
509 : Iterator i;
510 1 : bool value_found[] = { false, false, false, false };
511 : char *val1, *val2, *val3, *val4, *s;
512 : unsigned count;
513 :
514 1 : log_info("/* %s */", __func__);
515 :
516 1 : val1 = strdup("my val1");
517 1 : assert_se(val1);
518 1 : val2 = strdup("my val2");
519 1 : assert_se(val2);
520 1 : val3 = strdup("my val3");
521 1 : assert_se(val3);
522 1 : val4 = strdup("my val4");
523 1 : assert_se(val4);
524 :
525 1 : m = NULL;
526 :
527 1 : count = 0;
528 1 : ORDERED_HASHMAP_FOREACH(s, m, i)
529 0 : count++;
530 1 : assert_se(count == 0);
531 :
532 1 : m = ordered_hashmap_new(&string_hash_ops);
533 :
534 1 : count = 0;
535 1 : ORDERED_HASHMAP_FOREACH(s, m, i)
536 0 : count++;
537 1 : assert_se(count == 0);
538 :
539 1 : ordered_hashmap_put(m, "Key 1", val1);
540 1 : ordered_hashmap_put(m, "Key 2", val2);
541 1 : ordered_hashmap_put(m, "Key 3", val3);
542 1 : ordered_hashmap_put(m, "Key 4", val4);
543 :
544 5 : ORDERED_HASHMAP_FOREACH(s, m, i) {
545 4 : if (!value_found[0] && streq(s, val1))
546 1 : value_found[0] = true;
547 3 : else if (!value_found[1] && streq(s, val2))
548 1 : value_found[1] = true;
549 2 : else if (!value_found[2] && streq(s, val3))
550 1 : value_found[2] = true;
551 1 : else if (!value_found[3] && streq(s, val4))
552 1 : value_found[3] = true;
553 : }
554 :
555 1 : assert_se(m);
556 1 : assert_se(value_found[0] && value_found[1] && value_found[2] && value_found[3]);
557 :
558 1 : ordered_hashmap_free_free(m);
559 1 : }
560 :
561 1 : static void test_ordered_hashmap_merge(void) {
562 : OrderedHashmap *m;
563 : OrderedHashmap *n;
564 : char *val1, *val2, *val3, *val4, *r;
565 :
566 1 : log_info("/* %s */", __func__);
567 :
568 1 : val1 = strdup("my val1");
569 1 : assert_se(val1);
570 1 : val2 = strdup("my val2");
571 1 : assert_se(val2);
572 1 : val3 = strdup("my val3");
573 1 : assert_se(val3);
574 1 : val4 = strdup("my val4");
575 1 : assert_se(val4);
576 :
577 1 : n = ordered_hashmap_new(&string_hash_ops);
578 1 : m = ordered_hashmap_new(&string_hash_ops);
579 :
580 1 : ordered_hashmap_put(m, "Key 1", val1);
581 1 : ordered_hashmap_put(m, "Key 2", val2);
582 1 : ordered_hashmap_put(n, "Key 3", val3);
583 1 : ordered_hashmap_put(n, "Key 4", val4);
584 :
585 1 : assert_se(ordered_hashmap_merge(m, n) == 0);
586 1 : r = ordered_hashmap_get(m, "Key 3");
587 1 : assert_se(r && streq(r, "my val3"));
588 1 : r = ordered_hashmap_get(m, "Key 4");
589 1 : assert_se(r && streq(r, "my val4"));
590 :
591 1 : assert_se(n);
592 1 : assert_se(m);
593 1 : ordered_hashmap_free(n);
594 1 : ordered_hashmap_free_free(m);
595 1 : }
596 :
597 1 : static void test_ordered_hashmap_contains(void) {
598 : OrderedHashmap *m;
599 : char *val1;
600 :
601 1 : log_info("/* %s */", __func__);
602 :
603 1 : val1 = strdup("my val");
604 1 : assert_se(val1);
605 :
606 1 : m = ordered_hashmap_new(&string_hash_ops);
607 :
608 1 : assert_se(!ordered_hashmap_contains(m, "Key 1"));
609 1 : ordered_hashmap_put(m, "Key 1", val1);
610 1 : assert_se(ordered_hashmap_contains(m, "Key 1"));
611 1 : assert_se(!ordered_hashmap_contains(m, "Key 2"));
612 :
613 1 : assert_se(!ordered_hashmap_contains(NULL, "Key 1"));
614 :
615 1 : assert_se(m);
616 1 : ordered_hashmap_free_free(m);
617 1 : }
618 :
619 1 : static void test_ordered_hashmap_isempty(void) {
620 : OrderedHashmap *m;
621 : char *val1;
622 :
623 1 : log_info("/* %s */", __func__);
624 :
625 1 : val1 = strdup("my val");
626 1 : assert_se(val1);
627 :
628 1 : m = ordered_hashmap_new(&string_hash_ops);
629 :
630 1 : assert_se(ordered_hashmap_isempty(m));
631 1 : ordered_hashmap_put(m, "Key 1", val1);
632 1 : assert_se(!ordered_hashmap_isempty(m));
633 :
634 1 : assert_se(m);
635 1 : ordered_hashmap_free_free(m);
636 1 : }
637 :
638 1 : static void test_ordered_hashmap_size(void) {
639 : OrderedHashmap *m;
640 : char *val1, *val2, *val3, *val4;
641 :
642 1 : log_info("/* %s */", __func__);
643 :
644 1 : val1 = strdup("my val");
645 1 : assert_se(val1);
646 1 : val2 = strdup("my val");
647 1 : assert_se(val2);
648 1 : val3 = strdup("my val");
649 1 : assert_se(val3);
650 1 : val4 = strdup("my val");
651 1 : assert_se(val4);
652 :
653 1 : assert_se(ordered_hashmap_size(NULL) == 0);
654 1 : assert_se(ordered_hashmap_buckets(NULL) == 0);
655 :
656 1 : m = ordered_hashmap_new(&string_hash_ops);
657 :
658 1 : ordered_hashmap_put(m, "Key 1", val1);
659 1 : ordered_hashmap_put(m, "Key 2", val2);
660 1 : ordered_hashmap_put(m, "Key 3", val3);
661 1 : ordered_hashmap_put(m, "Key 4", val4);
662 :
663 1 : assert_se(m);
664 1 : assert_se(ordered_hashmap_size(m) == 4);
665 1 : assert_se(ordered_hashmap_buckets(m) >= 4);
666 1 : ordered_hashmap_free_free(m);
667 1 : }
668 :
669 1 : static void test_ordered_hashmap_get(void) {
670 : OrderedHashmap *m;
671 : char *r;
672 : char *val;
673 :
674 1 : log_info("/* %s */", __func__);
675 :
676 1 : val = strdup("my val");
677 1 : assert_se(val);
678 :
679 1 : r = ordered_hashmap_get(NULL, "Key 1");
680 1 : assert_se(r == NULL);
681 :
682 1 : m = ordered_hashmap_new(&string_hash_ops);
683 :
684 1 : ordered_hashmap_put(m, "Key 1", val);
685 :
686 1 : r = ordered_hashmap_get(m, "Key 1");
687 1 : assert_se(streq(r, val));
688 :
689 1 : r = ordered_hashmap_get(m, "no such key");
690 1 : assert_se(r == NULL);
691 :
692 1 : assert_se(m);
693 1 : ordered_hashmap_free_free(m);
694 1 : }
695 :
696 1 : static void test_ordered_hashmap_get2(void) {
697 : OrderedHashmap *m;
698 : char *r;
699 : char *val;
700 1 : char key_orig[] = "Key 1";
701 : void *key_copy;
702 :
703 1 : log_info("/* %s */", __func__);
704 :
705 1 : val = strdup("my val");
706 1 : assert_se(val);
707 :
708 1 : key_copy = strdup(key_orig);
709 1 : assert_se(key_copy);
710 :
711 1 : r = ordered_hashmap_get2(NULL, key_orig, &key_copy);
712 1 : assert_se(r == NULL);
713 :
714 1 : m = ordered_hashmap_new(&string_hash_ops);
715 :
716 1 : ordered_hashmap_put(m, key_copy, val);
717 1 : key_copy = NULL;
718 :
719 1 : r = ordered_hashmap_get2(m, key_orig, &key_copy);
720 1 : assert_se(streq(r, val));
721 1 : assert_se(key_orig != key_copy);
722 1 : assert_se(streq(key_orig, key_copy));
723 :
724 1 : r = ordered_hashmap_get2(m, "no such key", NULL);
725 1 : assert_se(r == NULL);
726 :
727 1 : assert_se(m);
728 1 : ordered_hashmap_free_free_free(m);
729 1 : }
730 :
731 1103 : static void crippled_ordered_hashmap_func(const void *p, struct siphash *state) {
732 1103 : return trivial_hash_func(INT_TO_PTR(PTR_TO_INT(p) & 0xff), state);
733 : }
734 :
735 : static const struct hash_ops crippled_ordered_hashmap_ops = {
736 : .hash = crippled_ordered_hashmap_func,
737 : .compare = trivial_compare_func,
738 : };
739 :
740 1 : static void test_ordered_hashmap_many(void) {
741 : OrderedHashmap *h;
742 : unsigned i, j;
743 : void *v, *k;
744 1 : bool slow = slow_tests_enabled();
745 : const struct {
746 : const char *title;
747 : const struct hash_ops *ops;
748 : unsigned n_entries;
749 3 : } tests[] = {
750 1 : { "trivial_ordered_hashmap_ops", NULL, slow ? 1 << 20 : 240 },
751 1 : { "crippled_ordered_hashmap_ops", &crippled_ordered_hashmap_ops, slow ? 1 << 14 : 140 },
752 : };
753 :
754 1 : log_info("/* %s (%s) */", __func__, slow ? "slow" : "fast");
755 :
756 3 : for (j = 0; j < ELEMENTSOF(tests); j++) {
757 2 : usec_t ts = now(CLOCK_MONOTONIC), n;
758 : char b[FORMAT_TIMESPAN_MAX];
759 :
760 2 : assert_se(h = ordered_hashmap_new(tests[j].ops));
761 :
762 382 : for (i = 1; i < tests[j].n_entries*3; i+=3) {
763 380 : assert_se(ordered_hashmap_put(h, UINT_TO_PTR(i), UINT_TO_PTR(i)) >= 0);
764 380 : assert_se(PTR_TO_UINT(ordered_hashmap_get(h, UINT_TO_PTR(i))) == i);
765 : }
766 :
767 1140 : for (i = 1; i < tests[j].n_entries*3; i++)
768 1138 : assert_se(ordered_hashmap_contains(h, UINT_TO_PTR(i)) == (i % 3 == 1));
769 :
770 2 : log_info("%s %u <= %u * 0.8 = %g",
771 : tests[j].title, ordered_hashmap_size(h), ordered_hashmap_buckets(h), ordered_hashmap_buckets(h) * 0.8);
772 :
773 2 : assert_se(ordered_hashmap_size(h) <= ordered_hashmap_buckets(h) * 0.8);
774 2 : assert_se(ordered_hashmap_size(h) == tests[j].n_entries);
775 :
776 382 : while (!ordered_hashmap_isempty(h)) {
777 380 : k = ordered_hashmap_first_key(h);
778 380 : v = ordered_hashmap_remove(h, k);
779 380 : assert_se(v == k);
780 : }
781 :
782 2 : ordered_hashmap_free(h);
783 :
784 2 : n = now(CLOCK_MONOTONIC);
785 2 : log_info("test took %s", format_timespan(b, sizeof b, n - ts, 0));
786 : }
787 1 : }
788 :
789 : extern unsigned custom_counter;
790 : extern const struct hash_ops boring_hash_ops, custom_hash_ops;
791 :
792 1 : static void test_ordered_hashmap_free(void) {
793 : OrderedHashmap *h;
794 1 : bool slow = slow_tests_enabled();
795 : usec_t ts, n;
796 : char b[FORMAT_TIMESPAN_MAX];
797 1 : unsigned n_entries = slow ? 1 << 20 : 240;
798 :
799 : const struct {
800 : const char *title;
801 : const struct hash_ops *ops;
802 : unsigned expect_counter;
803 2 : } tests[] = {
804 1 : { "string_hash_ops", &boring_hash_ops, 2 * n_entries},
805 : { "custom_free_hash_ops", &custom_hash_ops, 0 },
806 : };
807 :
808 1 : log_info("/* %s (%s, %u entries) */", __func__, slow ? "slow" : "fast", n_entries);
809 :
810 3 : for (unsigned j = 0; j < ELEMENTSOF(tests); j++) {
811 2 : ts = now(CLOCK_MONOTONIC);
812 2 : assert_se(h = ordered_hashmap_new(tests[j].ops));
813 :
814 2 : custom_counter = 0;
815 482 : for (unsigned i = 0; i < n_entries; i++) {
816 : char s[DECIMAL_STR_MAX(unsigned)];
817 : char *k, *v;
818 :
819 480 : xsprintf(s, "%u", i);
820 480 : assert_se(k = strdup(s));
821 480 : assert_se(v = strdup(s));
822 480 : custom_counter += 2;
823 :
824 480 : assert_se(ordered_hashmap_put(h, k, v) >= 0);
825 : }
826 :
827 2 : ordered_hashmap_free(h);
828 :
829 2 : n = now(CLOCK_MONOTONIC);
830 2 : log_info("%s test took %s", tests[j].title, format_timespan(b, sizeof b, n - ts, 0));
831 :
832 2 : assert_se(custom_counter == tests[j].expect_counter);
833 : }
834 1 : }
835 :
836 : typedef struct Item {
837 : int seen;
838 : } Item;
839 3 : static void item_seen(Item *item) {
840 3 : item->seen++;
841 3 : }
842 :
843 1 : static void test_ordered_hashmap_free_with_destructor(void) {
844 : OrderedHashmap *m;
845 1 : struct Item items[4] = {};
846 : unsigned i;
847 :
848 1 : log_info("/* %s */", __func__);
849 :
850 1 : assert_se(m = ordered_hashmap_new(NULL));
851 4 : for (i = 0; i < ELEMENTSOF(items) - 1; i++)
852 3 : assert_se(ordered_hashmap_put(m, INT_TO_PTR(i), items + i) == 1);
853 :
854 4 : m = ordered_hashmap_free_with_destructor(m, item_seen);
855 1 : assert_se(items[0].seen == 1);
856 1 : assert_se(items[1].seen == 1);
857 1 : assert_se(items[2].seen == 1);
858 1 : assert_se(items[3].seen == 0);
859 1 : }
860 :
861 1 : static void test_ordered_hashmap_first(void) {
862 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
863 :
864 1 : log_info("/* %s */", __func__);
865 :
866 1 : m = ordered_hashmap_new(&string_hash_ops);
867 1 : assert_se(m);
868 :
869 1 : assert_se(!ordered_hashmap_first(m));
870 1 : assert_se(ordered_hashmap_put(m, "key 1", (void*) "val 1") == 1);
871 1 : assert_se(streq(ordered_hashmap_first(m), "val 1"));
872 1 : assert_se(ordered_hashmap_put(m, "key 2", (void*) "val 2") == 1);
873 : #ifdef ORDERED
874 1 : assert_se(streq(ordered_hashmap_first(m), "val 1"));
875 1 : assert_se(ordered_hashmap_remove(m, "key 1"));
876 1 : assert_se(streq(ordered_hashmap_first(m), "val 2"));
877 : #endif
878 1 : }
879 :
880 1 : static void test_ordered_hashmap_first_key(void) {
881 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
882 :
883 1 : log_info("/* %s */", __func__);
884 :
885 1 : m = ordered_hashmap_new(&string_hash_ops);
886 1 : assert_se(m);
887 :
888 1 : assert_se(!ordered_hashmap_first_key(m));
889 1 : assert_se(ordered_hashmap_put(m, "key 1", NULL) == 1);
890 1 : assert_se(streq(ordered_hashmap_first_key(m), "key 1"));
891 1 : assert_se(ordered_hashmap_put(m, "key 2", NULL) == 1);
892 : #ifdef ORDERED
893 1 : assert_se(streq(ordered_hashmap_first_key(m), "key 1"));
894 1 : assert_se(ordered_hashmap_remove(m, "key 1") == NULL);
895 1 : assert_se(streq(ordered_hashmap_first_key(m), "key 2"));
896 : #endif
897 1 : }
898 :
899 1 : static void test_ordered_hashmap_steal_first_key(void) {
900 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
901 :
902 1 : log_info("/* %s */", __func__);
903 :
904 1 : m = ordered_hashmap_new(&string_hash_ops);
905 1 : assert_se(m);
906 :
907 1 : assert_se(!ordered_hashmap_steal_first_key(m));
908 1 : assert_se(ordered_hashmap_put(m, "key 1", NULL) == 1);
909 1 : assert_se(streq(ordered_hashmap_steal_first_key(m), "key 1"));
910 :
911 1 : assert_se(ordered_hashmap_isempty(m));
912 1 : }
913 :
914 1 : static void test_ordered_hashmap_steal_first(void) {
915 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
916 1 : int seen[3] = {};
917 : char *val;
918 :
919 1 : log_info("/* %s */", __func__);
920 :
921 1 : m = ordered_hashmap_new(&string_hash_ops);
922 1 : assert_se(m);
923 :
924 1 : assert_se(ordered_hashmap_put(m, "key 1", (void*) "1") == 1);
925 1 : assert_se(ordered_hashmap_put(m, "key 2", (void*) "22") == 1);
926 1 : assert_se(ordered_hashmap_put(m, "key 3", (void*) "333") == 1);
927 :
928 4 : while ((val = ordered_hashmap_steal_first(m)))
929 3 : seen[strlen(val) - 1]++;
930 :
931 1 : assert_se(seen[0] == 1 && seen[1] == 1 && seen[2] == 1);
932 :
933 1 : assert_se(ordered_hashmap_isempty(m));
934 1 : }
935 :
936 1 : static void test_ordered_hashmap_clear_free_free(void) {
937 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
938 :
939 1 : log_info("/* %s */", __func__);
940 :
941 1 : m = ordered_hashmap_new(&string_hash_ops);
942 1 : assert_se(m);
943 :
944 1 : assert_se(ordered_hashmap_put(m, strdup("key 1"), NULL) == 1);
945 1 : assert_se(ordered_hashmap_put(m, strdup("key 2"), NULL) == 1);
946 1 : assert_se(ordered_hashmap_put(m, strdup("key 3"), NULL) == 1);
947 :
948 1 : ordered_hashmap_clear_free_free(m);
949 1 : assert_se(ordered_hashmap_isempty(m));
950 :
951 1 : assert_se(ordered_hashmap_put(m, strdup("key 1"), strdup("value 1")) == 1);
952 1 : assert_se(ordered_hashmap_put(m, strdup("key 2"), strdup("value 2")) == 1);
953 1 : assert_se(ordered_hashmap_put(m, strdup("key 3"), strdup("value 3")) == 1);
954 :
955 1 : ordered_hashmap_clear_free_free(m);
956 1 : assert_se(ordered_hashmap_isempty(m));
957 1 : }
958 :
959 3 : DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(test_hash_ops_key, char, string_hash_func, string_compare_func, free);
960 6 : DEFINE_PRIVATE_HASH_OPS_FULL(test_hash_ops_full, char, string_hash_func, string_compare_func, free, char, free);
961 :
962 1 : static void test_ordered_hashmap_clear_free_with_destructor(void) {
963 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
964 :
965 1 : log_info("/* %s */", __func__);
966 :
967 1 : m = ordered_hashmap_new(&test_hash_ops_key);
968 1 : assert_se(m);
969 :
970 1 : assert_se(ordered_hashmap_put(m, strdup("key 1"), NULL) == 1);
971 1 : assert_se(ordered_hashmap_put(m, strdup("key 2"), NULL) == 1);
972 1 : assert_se(ordered_hashmap_put(m, strdup("key 3"), NULL) == 1);
973 :
974 1 : ordered_hashmap_clear_free(m);
975 1 : assert_se(ordered_hashmap_isempty(m));
976 1 : m = ordered_hashmap_free(m);
977 :
978 1 : m = ordered_hashmap_new(&test_hash_ops_full);
979 1 : assert_se(m);
980 :
981 1 : assert_se(ordered_hashmap_put(m, strdup("key 1"), strdup("value 1")) == 1);
982 1 : assert_se(ordered_hashmap_put(m, strdup("key 2"), strdup("value 2")) == 1);
983 1 : assert_se(ordered_hashmap_put(m, strdup("key 3"), strdup("value 3")) == 1);
984 :
985 1 : ordered_hashmap_clear_free(m);
986 1 : assert_se(ordered_hashmap_isempty(m));
987 1 : }
988 :
989 1 : static void test_ordered_hashmap_reserve(void) {
990 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
991 :
992 1 : log_info("/* %s */", __func__);
993 :
994 1 : m = ordered_hashmap_new(&string_hash_ops);
995 :
996 1 : assert_se(ordered_hashmap_reserve(m, 1) == 0);
997 1 : assert_se(ordered_hashmap_buckets(m) < 1000);
998 1 : assert_se(ordered_hashmap_reserve(m, 1000) == 0);
999 1 : assert_se(ordered_hashmap_buckets(m) >= 1000);
1000 1 : assert_se(ordered_hashmap_isempty(m));
1001 :
1002 1 : assert_se(ordered_hashmap_put(m, "key 1", (void*) "val 1") == 1);
1003 :
1004 1 : assert_se(ordered_hashmap_reserve(m, UINT_MAX) == -ENOMEM);
1005 1 : assert_se(ordered_hashmap_reserve(m, UINT_MAX - 1) == -ENOMEM);
1006 1 : }
1007 :
1008 1 : static void test_path_ordered_hashmap(void) {
1009 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *h = NULL;
1010 :
1011 1 : log_info("/* %s */", __func__);
1012 :
1013 1 : assert_se(h = ordered_hashmap_new(&path_hash_ops));
1014 :
1015 1 : assert_se(ordered_hashmap_put(h, "foo", INT_TO_PTR(1)) >= 0);
1016 1 : assert_se(ordered_hashmap_put(h, "/foo", INT_TO_PTR(2)) >= 0);
1017 1 : assert_se(ordered_hashmap_put(h, "//foo", INT_TO_PTR(3)) == -EEXIST);
1018 1 : assert_se(ordered_hashmap_put(h, "//foox/", INT_TO_PTR(4)) >= 0);
1019 1 : assert_se(ordered_hashmap_put(h, "/foox////", INT_TO_PTR(5)) == -EEXIST);
1020 1 : assert_se(ordered_hashmap_put(h, "foo//////bar/quux//", INT_TO_PTR(6)) >= 0);
1021 1 : assert_se(ordered_hashmap_put(h, "foo/bar//quux/", INT_TO_PTR(8)) == -EEXIST);
1022 :
1023 1 : assert_se(ordered_hashmap_get(h, "foo") == INT_TO_PTR(1));
1024 1 : assert_se(ordered_hashmap_get(h, "foo/") == INT_TO_PTR(1));
1025 1 : assert_se(ordered_hashmap_get(h, "foo////") == INT_TO_PTR(1));
1026 1 : assert_se(ordered_hashmap_get(h, "/foo") == INT_TO_PTR(2));
1027 1 : assert_se(ordered_hashmap_get(h, "//foo") == INT_TO_PTR(2));
1028 1 : assert_se(ordered_hashmap_get(h, "/////foo////") == INT_TO_PTR(2));
1029 1 : assert_se(ordered_hashmap_get(h, "/////foox////") == INT_TO_PTR(4));
1030 1 : assert_se(ordered_hashmap_get(h, "/foox/") == INT_TO_PTR(4));
1031 1 : assert_se(ordered_hashmap_get(h, "/foox") == INT_TO_PTR(4));
1032 1 : assert_se(!ordered_hashmap_get(h, "foox"));
1033 1 : assert_se(ordered_hashmap_get(h, "foo/bar/quux") == INT_TO_PTR(6));
1034 1 : assert_se(ordered_hashmap_get(h, "foo////bar////quux/////") == INT_TO_PTR(6));
1035 1 : assert_se(!ordered_hashmap_get(h, "/foo////bar////quux/////"));
1036 1 : }
1037 :
1038 1 : static void test_string_strv_ordered_hashmap(void) {
1039 1 : _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
1040 : char **s;
1041 :
1042 1 : log_info("/* %s */", __func__);
1043 :
1044 1 : assert_se(string_strv_ordered_hashmap_put(&m, "foo", "bar") == 1);
1045 1 : assert_se(string_strv_ordered_hashmap_put(&m, "foo", "bar") == 0);
1046 1 : assert_se(string_strv_ordered_hashmap_put(&m, "foo", "BAR") == 1);
1047 1 : assert_se(string_strv_ordered_hashmap_put(&m, "foo", "BAR") == 0);
1048 1 : assert_se(string_strv_ordered_hashmap_put(&m, "foo", "bar") == 0);
1049 1 : assert_se(ordered_hashmap_contains(m, "foo"));
1050 :
1051 1 : s = ordered_hashmap_get(m, "foo");
1052 1 : assert_se(strv_equal(s, STRV_MAKE("bar", "BAR")));
1053 :
1054 1 : assert_se(string_strv_ordered_hashmap_put(&m, "xxx", "bar") == 1);
1055 1 : assert_se(string_strv_ordered_hashmap_put(&m, "xxx", "bar") == 0);
1056 1 : assert_se(string_strv_ordered_hashmap_put(&m, "xxx", "BAR") == 1);
1057 1 : assert_se(string_strv_ordered_hashmap_put(&m, "xxx", "BAR") == 0);
1058 1 : assert_se(string_strv_ordered_hashmap_put(&m, "xxx", "bar") == 0);
1059 1 : assert_se(ordered_hashmap_contains(m, "xxx"));
1060 :
1061 1 : s = ordered_hashmap_get(m, "xxx");
1062 1 : assert_se(strv_equal(s, STRV_MAKE("bar", "BAR")));
1063 1 : }
1064 :
1065 1 : void test_ordered_hashmap_funcs(void) {
1066 1 : log_info("/************ %s ************/", __func__);
1067 :
1068 1 : test_ordered_hashmap_copy();
1069 1 : test_ordered_hashmap_get_strv();
1070 1 : test_ordered_hashmap_move_one();
1071 1 : test_ordered_hashmap_move();
1072 1 : test_ordered_hashmap_replace();
1073 1 : test_ordered_hashmap_update();
1074 1 : test_ordered_hashmap_put();
1075 1 : test_ordered_hashmap_remove();
1076 1 : test_ordered_hashmap_remove2();
1077 1 : test_ordered_hashmap_remove_value();
1078 1 : test_ordered_hashmap_remove_and_put();
1079 1 : test_ordered_hashmap_remove_and_replace();
1080 1 : test_ordered_hashmap_ensure_allocated();
1081 1 : test_ordered_hashmap_foreach();
1082 1 : test_ordered_hashmap_foreach_key();
1083 1 : test_ordered_hashmap_contains();
1084 1 : test_ordered_hashmap_merge();
1085 1 : test_ordered_hashmap_isempty();
1086 1 : test_ordered_hashmap_get();
1087 1 : test_ordered_hashmap_get2();
1088 1 : test_ordered_hashmap_size();
1089 1 : test_ordered_hashmap_many();
1090 1 : test_ordered_hashmap_free();
1091 1 : test_ordered_hashmap_free_with_destructor();
1092 1 : test_ordered_hashmap_first();
1093 1 : test_ordered_hashmap_first_key();
1094 1 : test_ordered_hashmap_steal_first_key();
1095 1 : test_ordered_hashmap_steal_first();
1096 1 : test_ordered_hashmap_clear_free_free();
1097 1 : test_ordered_hashmap_clear_free_with_destructor();
1098 1 : test_ordered_hashmap_reserve();
1099 1 : test_path_ordered_hashmap();
1100 1 : test_string_strv_ordered_hashmap();
1101 1 : }
|