check-qdict: Introduce test for the new iteration API
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
f2b07f35d2
commit
d02c6bd428
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user