From nobody Mon Feb 9 14:34:00 2026 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 1487068125715248.28034156056526; Tue, 14 Feb 2017 02:28:45 -0800 (PST) Received: from localhost ([::1]:33702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdaLi-0007rg-D8 for importer@patchew.org; Tue, 14 Feb 2017 05:28:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdaJO-0005qc-FN for qemu-devel@nongnu.org; Tue, 14 Feb 2017 05:26:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdaJM-0003M4-AT for qemu-devel@nongnu.org; Tue, 14 Feb 2017 05:26:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53130) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cdaJM-0003LO-5U for qemu-devel@nongnu.org; Tue, 14 Feb 2017 05:26:16 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 5935C3D955 for ; Tue, 14 Feb 2017 10:26:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1EAQFtg023206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Feb 2017 05:26:16 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9F9F911384B8; Tue, 14 Feb 2017 11:26:11 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 14 Feb 2017 11:25:59 +0100 Message-Id: <1487067971-10443-13-git-send-email-armbru@redhat.com> In-Reply-To: <1487067971-10443-1-git-send-email-armbru@redhat.com> References: <1487067971-10443-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 14 Feb 2017 10:26:16 +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] [PATCH 12/24] tests/test-cutils: Cover qemu_strtosz() with trailing crap 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" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- tests/test-cutils.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test-cutils.c b/tests/test-cutils.c index 3dcd4c1..ec65d27 100644 --- a/tests/test-cutils.c +++ b/tests/test-cutils.c @@ -1463,6 +1463,23 @@ static void test_qemu_strtosz_invalid(void) g_assert(endptr =3D=3D str); } =20 +static void test_qemu_strtosz_trailing(void) +{ + const char *str; + char *endptr =3D NULL; + int64_t res; + + str =3D "123xxx"; + res =3D qemu_strtosz(str, &endptr); + g_assert_cmpint(res, =3D=3D, 123 * M_BYTE); + g_assert(endptr =3D=3D str + 3); + + str =3D "1kiB"; + res =3D qemu_strtosz(str, &endptr); + g_assert_cmpint(res, =3D=3D, 1024); + g_assert(endptr =3D=3D str + 2); +} + static void test_qemu_strtosz_erange(void) { const char *str =3D "10E"; @@ -1676,6 +1693,8 @@ int main(int argc, char **argv) test_qemu_strtosz_float); g_test_add_func("/cutils/strtosz/invalid", test_qemu_strtosz_invalid); + g_test_add_func("/cutils/strtosz/trailing", + test_qemu_strtosz_trailing); g_test_add_func("/cutils/strtosz/erange", test_qemu_strtosz_erange); g_test_add_func("/cutils/strtosz/suffix-unit", --=20 2.7.4