From patchwork Tue Jun 22 17:40:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 56548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3E13DB6EF3 for ; Wed, 23 Jun 2010 03:47:49 +1000 (EST) Received: from localhost ([127.0.0.1]:58775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OR7Za-00085k-Dp for incoming@patchwork.ozlabs.org; Tue, 22 Jun 2010 13:47:46 -0400 Received: from [140.186.70.92] (port=55543 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OR7TM-0004RO-NH for qemu-devel@nongnu.org; Tue, 22 Jun 2010 13:41:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OR7TG-0000bS-CD for qemu-devel@nongnu.org; Tue, 22 Jun 2010 13:41:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10034) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OR7TG-0000bG-46 for qemu-devel@nongnu.org; Tue, 22 Jun 2010 13:41:14 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5MHfCdH031904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Jun 2010 13:41:13 -0400 Received: from localhost (vpn-10-15.rdu.redhat.com [10.11.10.15]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5MHfBqc029170; Tue, 22 Jun 2010 13:41:12 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 22 Jun 2010 14:40:43 -0300 Message-Id: <1277228451-7741-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1277228451-7741-1-git-send-email-lcapitulino@redhat.com> References: <1277228451-7741-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 05/13] check-qdict: Introduce test for the new iteration API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Luiz Capitulino --- check-qdict.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/check-qdict.c b/check-qdict.c index 1b070f4..6afce5a 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);