From f8dca426546b969b61ce9186b3321ddc9b28671a Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Mon, 7 Jun 2010 15:29:58 -0300 Subject: check-qdict: Introduce test for the new iteration API Signed-off-by: Luiz Capitulino --- check-qdict.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'check-qdict.c') 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); -- cgit v1.2.3