From nobody Thu Nov 6 20:29:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487792423731891.7769511556403; Wed, 22 Feb 2017 11:40:23 -0800 (PST) Received: from localhost ([::1]:54985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgclw-0002J1-Bz for importer@patchew.org; Wed, 22 Feb 2017 14:40:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNZ-0004iI-U2 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNT-0000f3-0z for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000e9-P7 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:02 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06B196AADE for ; Wed, 22 Feb 2017 19:15:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MJF14h025339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 22 Feb 2017 14:15:02 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 76B65113860A; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:56 +0100 Message-Id: <1487790898-24921-15-git-send-email-armbru@redhat.com> In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com> References: <1487790898-24921-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 22 Feb 2017 19:15:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/16] tests: Don't check qobject_type() before qobject_to_qbool() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qobject_to_qbool(obj) returns NULL when obj isn't a QBool. Check that instead of qobject_type(obj) =3D=3D QTYPE_QBOOL. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-13-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qjson.c | 24 ++++++------------------ tests/test-qobject-output-visitor.c | 12 +++++------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 591b70a..e6d6935 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -966,10 +966,8 @@ static void keyword_literal(void) QString *str; =20 obj =3D qobject_from_json("true"); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - qbool =3D qobject_to_qbool(obj); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); =20 str =3D qobject_to_json(obj); @@ -979,10 +977,8 @@ static void keyword_literal(void) QDECREF(qbool); =20 obj =3D qobject_from_json("false"); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - qbool =3D qobject_to_qbool(obj); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D false); =20 str =3D qobject_to_json(obj); @@ -991,23 +987,15 @@ static void keyword_literal(void) =20 QDECREF(qbool); =20 - obj =3D qobject_from_jsonf("%i", false); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - - qbool =3D qobject_to_qbool(obj); + qbool =3D qobject_to_qbool(qobject_from_jsonf("%i", false)); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D false); - QDECREF(qbool); =20 /* Test that non-zero values other than 1 get collapsed to true */ - obj =3D qobject_from_jsonf("%i", 2); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - - qbool =3D qobject_to_qbool(obj); + qbool =3D qobject_to_qbool(qobject_from_jsonf("%i", 2)); + g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); - QDECREF(qbool); =20 obj =3D qobject_from_json("null"); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 5617fd3..500b452 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -71,13 +71,13 @@ static void test_visitor_out_bool(TestOutputVisitorData= *data, const void *unused) { bool value =3D true; - QObject *obj; + QBool *qbool; =20 visit_type_bool(data->ov, NULL, &value, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); - g_assert(qbool_get_bool(qobject_to_qbool(obj)) =3D=3D value); + qbool =3D qobject_to_qbool(visitor_get(data)); + g_assert(qbool); + g_assert(qbool_get_bool(qbool) =3D=3D value); } =20 static void test_visitor_out_number(TestOutputVisitorData *data, @@ -356,9 +356,7 @@ static void test_visitor_out_any(TestOutputVisitorData = *data, qint =3D qobject_to_qint(qdict_get(qdict, "integer")); g_assert(qint); g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); - qobj =3D qdict_get(qdict, "boolean"); - g_assert(qobj); - qbool =3D qobject_to_qbool(qobj); + qbool =3D qobject_to_qbool(qdict_get(qdict, "boolean")); g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); qstring =3D qobject_to_qstring(qdict_get(qdict, "string")); --=20 2.7.4