summaryrefslogtreecommitdiff
path: root/check-qdict.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2010-06-07 15:29:58 -0300
committerLuiz Capitulino <lcapitulino@redhat.com>2010-07-01 14:27:13 -0300
commitf8dca426546b969b61ce9186b3321ddc9b28671a (patch)
tree84e6e930dddeac4d3af1419cb5657b1d4880bb49 /check-qdict.c
parent245141b831f1141fb54986864e5fd553bc876c82 (diff)
downloadqemu-f8dca426546b969b61ce9186b3321ddc9b28671a.tar.gz
qemu-f8dca426546b969b61ce9186b3321ddc9b28671a.tar.bz2
qemu-f8dca426546b969b61ce9186b3321ddc9b28671a.zip
check-qdict: Introduce test for the new iteration API
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'check-qdict.c')
-rw-r--r--check-qdict.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/check-qdict.c b/check-qdict.c
index 1b070f4864..6afce5a5ca 100644
--- a/check-qdict.c
+++ b/check-qdict.c
@@ -194,6 +194,36 @@ START_TEST(qobject_to_qdict_test)
}
END_TEST
+START_TEST(qdict_iterapi_test)
+{
+ int count;
+ const QDictEntry *ent;
+
+ fail_unless(qdict_first(tests_dict) == NULL);
+
+ qdict_put(tests_dict, "key1", qint_from_int(1));
+ qdict_put(tests_dict, "key2", qint_from_int(2));
+ qdict_put(tests_dict, "key3", qint_from_int(3));
+
+ count = 0;
+ for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){
+ fail_unless(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1);
+ count++;
+ }
+
+ fail_unless(count == qdict_size(tests_dict));
+
+ /* Do it again to test restarting */
+ count = 0;
+ for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){
+ fail_unless(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1);
+ count++;
+ }
+
+ fail_unless(count == qdict_size(tests_dict));
+}
+END_TEST
+
/*
* Errors test-cases
*/
@@ -338,6 +368,7 @@ static Suite *qdict_suite(void)
tcase_add_test(qdict_public2_tcase, qdict_haskey_test);
tcase_add_test(qdict_public2_tcase, qdict_del_test);
tcase_add_test(qdict_public2_tcase, qobject_to_qdict_test);
+ tcase_add_test(qdict_public2_tcase, qdict_iterapi_test);
qdict_errors_tcase = tcase_create("Errors");
suite_add_tcase(s, qdict_errors_tcase);