4 * Copyright (C) 2009 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "qapi/qmp/qdict.h"
15 #include "qapi/qmp/qlist.h"
16 #include "qapi/qmp/qnum.h"
17 #include "qapi/qmp/qstring.h"
18 #include "qapi/error.h"
19 #include "qemu-common.h"
22 * Public Interface test-cases
24 * (with some violations to access 'private' data)
27 static void qdict_new_test(void)
32 g_assert(qdict
!= NULL
);
33 g_assert(qdict_size(qdict
) == 0);
34 g_assert(qdict
->base
.refcnt
== 1);
35 g_assert(qobject_type(QOBJECT(qdict
)) == QTYPE_QDICT
);
40 static void qdict_put_obj_test(void)
49 // key "" will have tdb hash 12345
50 qdict_put_int(qdict
, "", num
);
52 g_assert(qdict_size(qdict
) == 1);
53 ent
= QLIST_FIRST(&qdict
->table
[12345 % QDICT_BUCKET_MAX
]);
54 qn
= qobject_to(QNum
, ent
->value
);
55 g_assert_cmpint(qnum_get_int(qn
), ==, num
);
60 static void qdict_destroy_simple_test(void)
65 qdict_put_int(qdict
, "num", 0);
66 qdict_put_str(qdict
, "str", "foo");
71 static void qdict_get_test(void)
75 const int value
= -42;
76 const char *key
= "test";
77 QDict
*tests_dict
= qdict_new();
79 qdict_put_int(tests_dict
, key
, value
);
81 obj
= qdict_get(tests_dict
, key
);
82 g_assert(obj
!= NULL
);
84 qn
= qobject_to(QNum
, obj
);
85 g_assert_cmpint(qnum_get_int(qn
), ==, value
);
90 static void qdict_get_int_test(void)
93 const int value
= 100;
94 const char *key
= "int";
95 QDict
*tests_dict
= qdict_new();
97 qdict_put_int(tests_dict
, key
, value
);
99 ret
= qdict_get_int(tests_dict
, key
);
100 g_assert(ret
== value
);
105 static void qdict_get_try_int_test(void)
108 const int value
= 100;
109 const char *key
= "int";
110 QDict
*tests_dict
= qdict_new();
112 qdict_put_int(tests_dict
, key
, value
);
113 qdict_put_str(tests_dict
, "string", "test");
115 ret
= qdict_get_try_int(tests_dict
, key
, 0);
116 g_assert(ret
== value
);
118 ret
= qdict_get_try_int(tests_dict
, "missing", -42);
119 g_assert_cmpuint(ret
, ==, -42);
121 ret
= qdict_get_try_int(tests_dict
, "string", -42);
122 g_assert_cmpuint(ret
, ==, -42);
127 static void qdict_get_str_test(void)
130 const char *key
= "key";
131 const char *str
= "string";
132 QDict
*tests_dict
= qdict_new();
134 qdict_put_str(tests_dict
, key
, str
);
136 p
= qdict_get_str(tests_dict
, key
);
138 g_assert(strcmp(p
, str
) == 0);
143 static void qdict_get_try_str_test(void)
146 const char *key
= "key";
147 const char *str
= "string";
148 QDict
*tests_dict
= qdict_new();
150 qdict_put_str(tests_dict
, key
, str
);
152 p
= qdict_get_try_str(tests_dict
, key
);
154 g_assert(strcmp(p
, str
) == 0);
159 static void qdict_defaults_test(void)
166 qdict_set_default_str(dict
, "foo", "abc");
167 qdict_set_default_str(dict
, "foo", "def");
168 g_assert_cmpstr(qdict_get_str(dict
, "foo"), ==, "abc");
169 qdict_set_default_str(dict
, "bar", "ghi");
171 qdict_copy_default(copy
, dict
, "foo");
172 g_assert_cmpstr(qdict_get_str(copy
, "foo"), ==, "abc");
173 qdict_set_default_str(copy
, "bar", "xyz");
174 qdict_copy_default(copy
, dict
, "bar");
175 g_assert_cmpstr(qdict_get_str(copy
, "bar"), ==, "xyz");
181 static void qdict_haskey_not_test(void)
183 QDict
*tests_dict
= qdict_new();
184 g_assert(qdict_haskey(tests_dict
, "test") == 0);
189 static void qdict_haskey_test(void)
191 const char *key
= "test";
192 QDict
*tests_dict
= qdict_new();
194 qdict_put_int(tests_dict
, key
, 0);
195 g_assert(qdict_haskey(tests_dict
, key
) == 1);
200 static void qdict_del_test(void)
202 const char *key
= "key test";
203 QDict
*tests_dict
= qdict_new();
205 qdict_put_str(tests_dict
, key
, "foo");
206 g_assert(qdict_size(tests_dict
) == 1);
208 qdict_del(tests_dict
, key
);
210 g_assert(qdict_size(tests_dict
) == 0);
211 g_assert(qdict_haskey(tests_dict
, key
) == 0);
216 static void qobject_to_qdict_test(void)
218 QDict
*tests_dict
= qdict_new();
219 g_assert(qobject_to(QDict
, QOBJECT(tests_dict
)) == tests_dict
);
224 static void qdict_iterapi_test(void)
227 const QDictEntry
*ent
;
228 QDict
*tests_dict
= qdict_new();
230 g_assert(qdict_first(tests_dict
) == NULL
);
232 qdict_put_int(tests_dict
, "key1", 1);
233 qdict_put_int(tests_dict
, "key2", 2);
234 qdict_put_int(tests_dict
, "key3", 3);
237 for (ent
= qdict_first(tests_dict
); ent
; ent
= qdict_next(tests_dict
, ent
)){
238 g_assert(qdict_haskey(tests_dict
, qdict_entry_key(ent
)) == 1);
242 g_assert(count
== qdict_size(tests_dict
));
244 /* Do it again to test restarting */
246 for (ent
= qdict_first(tests_dict
); ent
; ent
= qdict_next(tests_dict
, ent
)){
247 g_assert(qdict_haskey(tests_dict
, qdict_entry_key(ent
)) == 1);
251 g_assert(count
== qdict_size(tests_dict
));
256 static void qdict_flatten_test(void)
258 QList
*list1
= qlist_new();
259 QList
*list2
= qlist_new();
260 QDict
*dict1
= qdict_new();
261 QDict
*dict2
= qdict_new();
262 QDict
*dict3
= qdict_new();
265 * Test the flattening of
300 qdict_put_int(dict1
, "a", 0);
301 qdict_put_int(dict1
, "b", 1);
303 qlist_append_int(list1
, 23);
304 qlist_append_int(list1
, 66);
305 qlist_append(list1
, dict1
);
306 qlist_append_int(list2
, 42);
307 qlist_append(list2
, list1
);
309 qdict_put_int(dict2
, "c", 2);
310 qdict_put_int(dict2
, "d", 3);
311 qdict_put(dict3
, "e", list2
);
312 qdict_put(dict3
, "f", dict2
);
313 qdict_put_int(dict3
, "g", 4);
315 qdict_flatten(dict3
);
317 g_assert(qdict_get_int(dict3
, "e.0") == 42);
318 g_assert(qdict_get_int(dict3
, "e.1.0") == 23);
319 g_assert(qdict_get_int(dict3
, "e.1.1") == 66);
320 g_assert(qdict_get_int(dict3
, "e.1.2.a") == 0);
321 g_assert(qdict_get_int(dict3
, "e.1.2.b") == 1);
322 g_assert(qdict_get_int(dict3
, "f.c") == 2);
323 g_assert(qdict_get_int(dict3
, "f.d") == 3);
324 g_assert(qdict_get_int(dict3
, "g") == 4);
326 g_assert(qdict_size(dict3
) == 8);
331 static void qdict_array_split_test(void)
333 QDict
*test_dict
= qdict_new();
334 QDict
*dict1
, *dict2
;
370 * (remaining in the old QDict)
372 * This example is given in the comment of qdict_array_split().
375 qdict_put_int(test_dict
, "1.x", 0);
376 qdict_put_int(test_dict
, "4.y", 1);
377 qdict_put_int(test_dict
, "0.a", 42);
378 qdict_put_int(test_dict
, "o.o", 7);
379 qdict_put_int(test_dict
, "0.b", 23);
380 qdict_put_int(test_dict
, "2", 66);
382 qdict_array_split(test_dict
, &test_list
);
384 dict1
= qobject_to(QDict
, qlist_pop(test_list
));
385 dict2
= qobject_to(QDict
, qlist_pop(test_list
));
386 int1
= qobject_to(QNum
, qlist_pop(test_list
));
391 g_assert(qlist_empty(test_list
));
395 g_assert(qdict_get_int(dict1
, "a") == 42);
396 g_assert(qdict_get_int(dict1
, "b") == 23);
398 g_assert(qdict_size(dict1
) == 2);
402 g_assert(qdict_get_int(dict2
, "x") == 0);
404 g_assert(qdict_size(dict2
) == 1);
408 g_assert_cmpint(qnum_get_int(int1
), ==, 66);
412 g_assert(qdict_get_int(test_dict
, "4.y") == 1);
413 g_assert(qdict_get_int(test_dict
, "o.o") == 7);
415 g_assert(qdict_size(test_dict
) == 2);
441 * That is, test whether splitting stops if there is both an entry with key
442 * of "%u" and other entries with keys prefixed "%u." for the same index.
445 test_dict
= qdict_new();
447 qdict_put_int(test_dict
, "0", 42);
448 qdict_put_int(test_dict
, "1", 23);
449 qdict_put_int(test_dict
, "1.x", 84);
451 qdict_array_split(test_dict
, &test_list
);
453 int1
= qobject_to(QNum
, qlist_pop(test_list
));
456 g_assert(qlist_empty(test_list
));
460 g_assert_cmpint(qnum_get_int(int1
), ==, 42);
464 g_assert(qdict_get_int(test_dict
, "1") == 23);
465 g_assert(qdict_get_int(test_dict
, "1.x") == 84);
467 g_assert(qdict_size(test_dict
) == 2);
472 static void qdict_array_entries_test(void)
474 QDict
*dict
= qdict_new();
476 g_assert_cmpint(qdict_array_entries(dict
, "foo."), ==, 0);
478 qdict_put_int(dict
, "bar", 0);
479 qdict_put_int(dict
, "baz.0", 0);
480 g_assert_cmpint(qdict_array_entries(dict
, "foo."), ==, 0);
482 qdict_put_int(dict
, "foo.1", 0);
483 g_assert_cmpint(qdict_array_entries(dict
, "foo."), ==, -EINVAL
);
484 qdict_put_int(dict
, "foo.0", 0);
485 g_assert_cmpint(qdict_array_entries(dict
, "foo."), ==, 2);
486 qdict_put_int(dict
, "foo.bar", 0);
487 g_assert_cmpint(qdict_array_entries(dict
, "foo."), ==, -EINVAL
);
488 qdict_del(dict
, "foo.bar");
490 qdict_put_int(dict
, "foo.2.a", 0);
491 qdict_put_int(dict
, "foo.2.b", 0);
492 qdict_put_int(dict
, "foo.2.c", 0);
493 g_assert_cmpint(qdict_array_entries(dict
, "foo."), ==, 3);
494 g_assert_cmpint(qdict_array_entries(dict
, ""), ==, -EINVAL
);
499 qdict_put_int(dict
, "1", 0);
500 g_assert_cmpint(qdict_array_entries(dict
, ""), ==, -EINVAL
);
501 qdict_put_int(dict
, "0", 0);
502 g_assert_cmpint(qdict_array_entries(dict
, ""), ==, 2);
503 qdict_put_int(dict
, "bar", 0);
504 g_assert_cmpint(qdict_array_entries(dict
, ""), ==, -EINVAL
);
505 qdict_del(dict
, "bar");
507 qdict_put_int(dict
, "2.a", 0);
508 qdict_put_int(dict
, "2.b", 0);
509 qdict_put_int(dict
, "2.c", 0);
510 g_assert_cmpint(qdict_array_entries(dict
, ""), ==, 3);
515 static void qdict_join_test(void)
517 QDict
*dict1
, *dict2
;
518 bool overwrite
= false;
524 /* Test everything once without overwrite and once with */
527 /* Test empty dicts */
528 qdict_join(dict1
, dict2
, overwrite
);
530 g_assert(qdict_size(dict1
) == 0);
531 g_assert(qdict_size(dict2
) == 0);
533 /* First iteration: Test movement */
534 /* Second iteration: Test empty source and non-empty destination */
535 qdict_put_int(dict2
, "foo", 42);
537 for (i
= 0; i
< 2; i
++) {
538 qdict_join(dict1
, dict2
, overwrite
);
540 g_assert(qdict_size(dict1
) == 1);
541 g_assert(qdict_size(dict2
) == 0);
543 g_assert(qdict_get_int(dict1
, "foo") == 42);
546 /* Test non-empty source and destination without conflict */
547 qdict_put_int(dict2
, "bar", 23);
549 qdict_join(dict1
, dict2
, overwrite
);
551 g_assert(qdict_size(dict1
) == 2);
552 g_assert(qdict_size(dict2
) == 0);
554 g_assert(qdict_get_int(dict1
, "foo") == 42);
555 g_assert(qdict_get_int(dict1
, "bar") == 23);
558 qdict_put_int(dict2
, "foo", 84);
560 qdict_join(dict1
, dict2
, overwrite
);
562 g_assert(qdict_size(dict1
) == 2);
563 g_assert(qdict_size(dict2
) == !overwrite
);
565 g_assert(qdict_get_int(dict1
, "foo") == (overwrite
? 84 : 42));
566 g_assert(qdict_get_int(dict1
, "bar") == 23);
569 g_assert(qdict_get_int(dict2
, "foo") == 84);
572 /* Check the references */
573 g_assert(qdict_get(dict1
, "foo")->refcnt
== 1);
574 g_assert(qdict_get(dict1
, "bar")->refcnt
== 1);
577 g_assert(qdict_get(dict2
, "foo")->refcnt
== 1);
581 qdict_del(dict1
, "foo");
582 qdict_del(dict1
, "bar");
585 qdict_del(dict2
, "foo");
588 while (overwrite
^= true);
594 static void qdict_crumple_test_recursive(void)
596 QDict
*src
, *dst
, *rule
, *vnc
, *acl
, *listen
;
600 qdict_put_str(src
, "vnc.listen.addr", "127.0.0.1");
601 qdict_put_str(src
, "vnc.listen.port", "5901");
602 qdict_put_str(src
, "vnc.acl.rules.0.match", "fred");
603 qdict_put_str(src
, "vnc.acl.rules.0.policy", "allow");
604 qdict_put_str(src
, "vnc.acl.rules.1.match", "bob");
605 qdict_put_str(src
, "vnc.acl.rules.1.policy", "deny");
606 qdict_put_str(src
, "vnc.acl.default", "deny");
607 qdict_put_str(src
, "vnc.acl..name", "acl0");
608 qdict_put_str(src
, "vnc.acl.rule..name", "acl0");
610 dst
= qobject_to(QDict
, qdict_crumple(src
, &error_abort
));
612 g_assert_cmpint(qdict_size(dst
), ==, 1);
614 vnc
= qdict_get_qdict(dst
, "vnc");
616 g_assert_cmpint(qdict_size(vnc
), ==, 3);
618 listen
= qdict_get_qdict(vnc
, "listen");
620 g_assert_cmpint(qdict_size(listen
), ==, 2);
621 g_assert_cmpstr("127.0.0.1", ==, qdict_get_str(listen
, "addr"));
622 g_assert_cmpstr("5901", ==, qdict_get_str(listen
, "port"));
624 acl
= qdict_get_qdict(vnc
, "acl");
626 g_assert_cmpint(qdict_size(acl
), ==, 3);
628 rules
= qdict_get_qlist(acl
, "rules");
630 g_assert_cmpint(qlist_size(rules
), ==, 2);
632 rule
= qobject_to(QDict
, qlist_pop(rules
));
634 g_assert_cmpint(qdict_size(rule
), ==, 2);
635 g_assert_cmpstr("fred", ==, qdict_get_str(rule
, "match"));
636 g_assert_cmpstr("allow", ==, qdict_get_str(rule
, "policy"));
639 rule
= qobject_to(QDict
, qlist_pop(rules
));
641 g_assert_cmpint(qdict_size(rule
), ==, 2);
642 g_assert_cmpstr("bob", ==, qdict_get_str(rule
, "match"));
643 g_assert_cmpstr("deny", ==, qdict_get_str(rule
, "policy"));
646 /* With recursive crumpling, we should see all names unescaped */
647 g_assert_cmpstr("acl0", ==, qdict_get_str(vnc
, "acl.name"));
648 g_assert_cmpstr("acl0", ==, qdict_get_str(acl
, "rule.name"));
654 static void qdict_crumple_test_empty(void)
660 dst
= (QDict
*)qdict_crumple(src
, &error_abort
);
662 g_assert_cmpint(qdict_size(dst
), ==, 0);
668 static int qdict_count_entries(QDict
*dict
)
673 for (e
= qdict_first(dict
); e
; e
= qdict_next(dict
, e
)) {
680 static void qdict_rename_keys_test(void)
682 QDict
*dict
= qdict_new();
684 QDictRenames
*renames
;
685 Error
*local_err
= NULL
;
687 qdict_put_str(dict
, "abc", "foo");
688 qdict_put_str(dict
, "abcdef", "bar");
689 qdict_put_int(dict
, "number", 42);
690 qdict_put_bool(dict
, "flag", true);
691 qdict_put_null(dict
, "nothing");
693 /* Empty rename list */
694 renames
= (QDictRenames
[]) {
695 { NULL
, "this can be anything" }
697 copy
= qdict_clone_shallow(dict
);
698 qdict_rename_keys(copy
, renames
, &error_abort
);
700 g_assert_cmpstr(qdict_get_str(copy
, "abc"), ==, "foo");
701 g_assert_cmpstr(qdict_get_str(copy
, "abcdef"), ==, "bar");
702 g_assert_cmpint(qdict_get_int(copy
, "number"), ==, 42);
703 g_assert_cmpint(qdict_get_bool(copy
, "flag"), ==, true);
704 g_assert(qobject_type(qdict_get(copy
, "nothing")) == QTYPE_QNULL
);
705 g_assert_cmpint(qdict_count_entries(copy
), ==, 5);
709 /* Simple rename of all entries */
710 renames
= (QDictRenames
[]) {
712 { "abcdef", "str2" },
715 { "nothing", "null" },
718 copy
= qdict_clone_shallow(dict
);
719 qdict_rename_keys(copy
, renames
, &error_abort
);
721 g_assert(!qdict_haskey(copy
, "abc"));
722 g_assert(!qdict_haskey(copy
, "abcdef"));
723 g_assert(!qdict_haskey(copy
, "number"));
724 g_assert(!qdict_haskey(copy
, "flag"));
725 g_assert(!qdict_haskey(copy
, "nothing"));
727 g_assert_cmpstr(qdict_get_str(copy
, "str1"), ==, "foo");
728 g_assert_cmpstr(qdict_get_str(copy
, "str2"), ==, "bar");
729 g_assert_cmpint(qdict_get_int(copy
, "int"), ==, 42);
730 g_assert_cmpint(qdict_get_bool(copy
, "bool"), ==, true);
731 g_assert(qobject_type(qdict_get(copy
, "null")) == QTYPE_QNULL
);
732 g_assert_cmpint(qdict_count_entries(copy
), ==, 5);
736 /* Renames are processed top to bottom */
737 renames
= (QDictRenames
[]) {
740 { "number", "abcdef" },
741 { "flag", "number" },
742 { "nothing", "flag" },
743 { "tmp", "nothing" },
746 copy
= qdict_clone_shallow(dict
);
747 qdict_rename_keys(copy
, renames
, &error_abort
);
749 g_assert_cmpstr(qdict_get_str(copy
, "nothing"), ==, "foo");
750 g_assert_cmpstr(qdict_get_str(copy
, "abc"), ==, "bar");
751 g_assert_cmpint(qdict_get_int(copy
, "abcdef"), ==, 42);
752 g_assert_cmpint(qdict_get_bool(copy
, "number"), ==, true);
753 g_assert(qobject_type(qdict_get(copy
, "flag")) == QTYPE_QNULL
);
754 g_assert(!qdict_haskey(copy
, "tmp"));
755 g_assert_cmpint(qdict_count_entries(copy
), ==, 5);
759 /* Conflicting rename */
760 renames
= (QDictRenames
[]) {
764 copy
= qdict_clone_shallow(dict
);
765 qdict_rename_keys(copy
, renames
, &local_err
);
767 g_assert(local_err
!= NULL
);
768 error_free(local_err
);
771 g_assert_cmpstr(qdict_get_str(copy
, "abc"), ==, "foo");
772 g_assert_cmpstr(qdict_get_str(copy
, "abcdef"), ==, "bar");
773 g_assert_cmpint(qdict_get_int(copy
, "number"), ==, 42);
774 g_assert_cmpint(qdict_get_bool(copy
, "flag"), ==, true);
775 g_assert(qobject_type(qdict_get(copy
, "nothing")) == QTYPE_QNULL
);
776 g_assert_cmpint(qdict_count_entries(copy
), ==, 5);
780 /* Renames in an empty dict */
781 renames
= (QDictRenames
[]) {
789 qdict_rename_keys(dict
, renames
, &error_abort
);
790 g_assert(qdict_first(dict
) == NULL
);
795 static void qdict_crumple_test_bad_inputs(void)
801 /* rule.0 can't be both a string and a dict */
802 qdict_put_str(src
, "rule.0", "fred");
803 qdict_put_str(src
, "rule.0.policy", "allow");
805 g_assert(qdict_crumple(src
, &error
) == NULL
);
806 g_assert(error
!= NULL
);
812 /* rule can't be both a list and a dict */
813 qdict_put_str(src
, "rule.0", "fred");
814 qdict_put_str(src
, "rule.a", "allow");
816 g_assert(qdict_crumple(src
, &error
) == NULL
);
817 g_assert(error
!= NULL
);
823 /* The input should be flat, ie no dicts or lists */
824 qdict_put(src
, "rule.a", qdict_new());
825 qdict_put_str(src
, "rule.b", "allow");
827 g_assert(qdict_crumple(src
, &error
) == NULL
);
828 g_assert(error
!= NULL
);
834 /* List indexes must not have gaps */
835 qdict_put_str(src
, "rule.0", "deny");
836 qdict_put_str(src
, "rule.3", "allow");
838 g_assert(qdict_crumple(src
, &error
) == NULL
);
839 g_assert(error
!= NULL
);
845 /* List indexes must be in %zu format */
846 qdict_put_str(src
, "rule.0", "deny");
847 qdict_put_str(src
, "rule.+1", "allow");
849 g_assert(qdict_crumple(src
, &error
) == NULL
);
850 g_assert(error
!= NULL
);
860 static void qdict_put_exists_test(void)
863 const char *key
= "exists";
864 QDict
*tests_dict
= qdict_new();
866 qdict_put_int(tests_dict
, key
, 1);
867 qdict_put_int(tests_dict
, key
, 2);
869 value
= qdict_get_int(tests_dict
, key
);
870 g_assert(value
== 2);
872 g_assert(qdict_size(tests_dict
) == 1);
877 static void qdict_get_not_exists_test(void)
879 QDict
*tests_dict
= qdict_new();
880 g_assert(qdict_get(tests_dict
, "foo") == NULL
);
888 * This is a lot big for a unit-test, but there is no other place
892 static void remove_dots(char *string
)
894 char *p
= strchr(string
, ':');
899 static QString
*read_line(FILE *file
, char *key
)
903 if (fscanf(file
, "%127s%127s", key
, value
) == EOF
) {
907 return qstring_from_str(value
);
910 #define reset_file(file) fseek(file, 0L, SEEK_SET)
912 static void qdict_stress_test(void)
919 const char *test_file_path
= "qdict-test-data.txt";
921 test_file
= fopen(test_file_path
, "r");
922 g_assert(test_file
!= NULL
);
926 g_assert(qdict
!= NULL
);
928 // Add everything from the test file
929 for (lines
= 0;; lines
++) {
930 value
= read_line(test_file
, key
);
934 qdict_put(qdict
, key
, value
);
936 g_assert(qdict_size(qdict
) == lines
);
938 // Check if everything is really in there
939 reset_file(test_file
);
941 const char *str1
, *str2
;
943 value
= read_line(test_file
, key
);
947 str1
= qstring_get_str(value
);
949 str2
= qdict_get_str(qdict
, key
);
950 g_assert(str2
!= NULL
);
952 g_assert(strcmp(str1
, str2
) == 0);
958 reset_file(test_file
);
960 value
= read_line(test_file
, key
);
964 qdict_del(qdict
, key
);
967 g_assert(qdict_haskey(qdict
, key
) == 0);
971 g_assert(qdict_size(qdict
) == 0);
975 int main(int argc
, char **argv
)
977 g_test_init(&argc
, &argv
, NULL
);
979 g_test_add_func("/public/new", qdict_new_test
);
980 g_test_add_func("/public/put_obj", qdict_put_obj_test
);
981 g_test_add_func("/public/destroy_simple", qdict_destroy_simple_test
);
983 /* Continue, but now with fixtures */
984 g_test_add_func("/public/get", qdict_get_test
);
985 g_test_add_func("/public/get_int", qdict_get_int_test
);
986 g_test_add_func("/public/get_try_int", qdict_get_try_int_test
);
987 g_test_add_func("/public/get_str", qdict_get_str_test
);
988 g_test_add_func("/public/get_try_str", qdict_get_try_str_test
);
989 g_test_add_func("/public/defaults", qdict_defaults_test
);
990 g_test_add_func("/public/haskey_not", qdict_haskey_not_test
);
991 g_test_add_func("/public/haskey", qdict_haskey_test
);
992 g_test_add_func("/public/del", qdict_del_test
);
993 g_test_add_func("/public/to_qdict", qobject_to_qdict_test
);
994 g_test_add_func("/public/iterapi", qdict_iterapi_test
);
995 g_test_add_func("/public/flatten", qdict_flatten_test
);
996 g_test_add_func("/public/array_split", qdict_array_split_test
);
997 g_test_add_func("/public/array_entries", qdict_array_entries_test
);
998 g_test_add_func("/public/join", qdict_join_test
);
1000 g_test_add_func("/errors/put_exists", qdict_put_exists_test
);
1001 g_test_add_func("/errors/get_not_exists", qdict_get_not_exists_test
);
1003 g_test_add_func("/public/crumple/recursive",
1004 qdict_crumple_test_recursive
);
1005 g_test_add_func("/public/crumple/empty",
1006 qdict_crumple_test_empty
);
1007 g_test_add_func("/public/crumple/bad_inputs",
1008 qdict_crumple_test_bad_inputs
);
1010 g_test_add_func("/public/rename_keys", qdict_rename_keys_test
);
1013 if (g_test_slow()) {
1014 g_test_add_func("/stress/test", qdict_stress_test
);
1017 return g_test_run();