From nobody Thu Nov 6 20:37:02 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 1487791512441781.8814852509; Wed, 22 Feb 2017 11:25:12 -0800 (PST) Received: from localhost ([::1]:54890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcXE-0005WK-UE for importer@patchew.org; Wed, 22 Feb 2017 14:25:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgcNU-0004dD-S8 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgcNS-0000eu-UT for qemu-devel@nongnu.org; Wed, 22 Feb 2017 14:15:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgcNS-0000e5-Ot 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 011AC3D95D 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 v1MJF1Fc025335 (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 73B501138607; Wed, 22 Feb 2017 20:14:58 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 20:14:55 +0100 Message-Id: <1487790898-24921-14-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.30]); 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 13/16] tests: Don't check qobject_type() before qobject_to_qfloat() 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_qfloat(obj) returns NULL when obj isn't a QFloat. Check that instead of qobject_type(obj) =3D=3D QTYPE_QFLOAT. Signed-off-by: Markus Armbruster Message-Id: <1487363905-9480-12-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/check-qjson.c | 12 ++---------- tests/test-qobject-output-visitor.c | 8 ++++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/check-qjson.c b/tests/check-qjson.c index aab4e0a..591b70a 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -921,10 +921,8 @@ static void float_number(void) QFloat *qfloat; =20 obj =3D qobject_from_json(test_cases[i].encoded); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QFLOAT); - qfloat =3D qobject_to_qfloat(obj); + g_assert(qfloat); g_assert(qfloat_get_double(qfloat) =3D=3D test_cases[i].decoded); =20 if (test_cases[i].skip =3D=3D 0) { @@ -941,7 +939,6 @@ static void float_number(void) =20 static void vararg_number(void) { - QObject *obj; QInt *qint; QFloat *qfloat; int value =3D 0x2342; @@ -956,13 +953,8 @@ static void vararg_number(void) g_assert(qint_get_int(qint) =3D=3D value_ll); QDECREF(qint); =20 - obj =3D qobject_from_jsonf("%f", valuef); - g_assert(obj !=3D NULL); - g_assert(qobject_type(obj) =3D=3D QTYPE_QFLOAT); - - qfloat =3D qobject_to_qfloat(obj); + qfloat =3D qobject_to_qfloat(qobject_from_jsonf("%f", valuef)); g_assert(qfloat_get_double(qfloat) =3D=3D valuef); - QDECREF(qfloat); } =20 diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 50b807e..5617fd3 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -84,13 +84,13 @@ static void test_visitor_out_number(TestOutputVisitorDa= ta *data, const void *unused) { double value =3D 3.14; - QObject *obj; + QFloat *qfloat; =20 visit_type_number(data->ov, NULL, &value, &error_abort); =20 - obj =3D visitor_get(data); - g_assert(qobject_type(obj) =3D=3D QTYPE_QFLOAT); - g_assert(qfloat_get_double(qobject_to_qfloat(obj)) =3D=3D value); + qfloat =3D qobject_to_qfloat(visitor_get(data)); + g_assert(qfloat); + g_assert(qfloat_get_double(qfloat) =3D=3D value); } =20 static void test_visitor_out_string(TestOutputVisitorData *data, --=20 2.7.4