From patchwork Wed Oct 18 10:52:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitrij Mijoski X-Patchwork-Id: 154854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4751041vqb; Wed, 18 Oct 2023 05:25:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmmxL3YINDRAN+7QnQQjfkW0HCUtEzlfdvr94ybpbW30li8TkQSfSqZ2u5Mbwsj3AiZxh8 X-Received: by 2002:ad4:5b83:0:b0:65d:660:25a8 with SMTP id 3-20020ad45b83000000b0065d066025a8mr6139772qvp.20.1697631956004; Wed, 18 Oct 2023 05:25:56 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1697631955; cv=pass; d=google.com; s=arc-20160816; b=or6L3G1WXrBOZkIO1Z8Y9KEJFVAFXlL3GpMvxi8+BtjsFGHyNRrUPPyXbCDHUv4Bqq xKEAv1/KlvZlPQ7O6ReApAJK3swG/vCUNI9xEsNPQupzBkoA7f7U4Agz6onc7LonuYtI 8arlebjLSPEDcH3umkpmhHu213vMe6a9vxKj0ZOkMYCGc3BCFTkXiVlT7WTCpTMQEndO X5PG6YGmIGN3ln6n+HJLle4nnAg6u1I3XJwljy6eO3YgTaaVjJ4ntMPv+wLDw/RvXVcB 9RmCOBgOoGal3SLlrVIybYtjmWETOYpxoflhHEyo42eXnbNHfmjN1aKnU1bN4IE8Cf3e tkdQ== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=pWKhyq7VAnIPKzmfoCybz/MajyTLj1sIsI1D8nlBNV8=; fh=+uLa3m5dEsZWyE738VC4UtcvjxY1kYREGLuytVVwtpk=; b=UTqy/N/7G3AlvmrzR7PH1iLwexUJ+tsPpZGo5l3PQhq1zo3o0W87mWiVQ5AdwM2RSo 4lsLGexs/1JntYXijXDO5TJ/ETzMOXjs7WOxrYctjLtnKePdPBwIQvohzd2dzCCoteHb qrvQh8HvUaPs29Co2UQ0qUajM4qWLsdn1kO0nqM9XTEROUAqTxkIW4OTA1XrD0M0e7qM UFuMzA/2fxeJ9+C080CRtD1bOdOBiQqrj0d4SNkYkh83hvNmtEB27CgLwVg3VR8v/ofD VXx8dxzwwp54EC4XtHUo/5WWfNwmdszlnDAQv7Do8SlnjZs112EABvZXAM/JZJzn9IjT f73A== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@hotmail.com header.s=selector1 header.b=jRwqNx5p; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hotmail.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d22-20020a05620a167600b0077437859065si2537234qko.535.2023.10.18.05.25.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:25:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@hotmail.com header.s=selector1 header.b=jRwqNx5p; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hotmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9BD6E38618D9 for ; Wed, 18 Oct 2023 10:52:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04olkn2052.outbound.protection.outlook.com [40.92.73.52]) by sourceware.org (Postfix) with ESMTPS id 980DF3858C30; Wed, 18 Oct 2023 10:52:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 980DF3858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=hotmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hotmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 980DF3858C30 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.92.73.52 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697626348; cv=pass; b=nMEsPD1kRmfNfB8GbwM/4s4rVu7xVZJBy+3IOX4njNyR6Yuf7LR7sIN3oUosVW7lAXEnoabJsjKh+0Iq8w2+RT897Lx/OAZ9bhZCu7YaxNWhiYabXcUgiDxqSgDho2Ez0lrO/iwjh3RBcPpYVoPzXf9uGhuZtdOzDq1oYHfxCdk= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697626348; c=relaxed/simple; bh=Cv/JSPF0gq+jyN5zTwUc4Z8OdfLyqWns07XuuhDLOAs=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=Z7zBjW0XJPX8RnyeTtsiAr+1n/vv3ma2s1/1fJ11S1kIHKDD8gMISU3UBFJNxx0VoWWnqtd7uNUlSQpL9q1+Wqs562+Un4JxBjsbHks+z9/2vXYF/7vzxs4YDKGYUTvp/ob91jxH22t5pflrXRLlb75aY23l/uky8A7az1sAFzM= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GNGzwNZ9ALg+MOiRN7AwSAh9V++WxexFc8fVcLi97HM198ap56a1w2vP/8G+x2nd0arff9418KdNi/Skf2YZL+Z1gUxjC19xplIWiasWdCE+aRU6D/Sgn0DZRyrrDrS2sw9LJYpi/4mGiaGKy/m/OYzGVpvZWxoqg8AJGGfyY0y92Q2s7EJFyCjg7xTbyaTtJ4juvbSwIiY4/6SeDzEAVJIr1Mrq9xnegQN0BOzZuN2T80GgyBAAK+LbJ1oLlG/ed6PdzKqXP4z/QLhd4pQADUPQFyUsvVr4f/ZdLmMJgtFt2qq8VNdeTIzig7ggTuHlWW4H+biKeU7B2QDOBksyaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pWKhyq7VAnIPKzmfoCybz/MajyTLj1sIsI1D8nlBNV8=; b=V/28WUFzrd996aY5Yn1vWAJwT3OUsei+PM/mg671qE9cgtHLC0ovdlbe360GNj5/o9aPow/ByGqjOkDDcjKH5Fwt8cndGMBQjmMP4L+/BlolBHhPfo9aluH57U2DbCXr6ieDVDpeUkxgOKCUZfRNXDqR84BH4wqkzrkR1TCec+cV5doDE/R/a4SCi/d95tM6YZTudKOhZbh4LhkNwnlx3E5sc/mzrhXaI9dYvRWTjBWGhJqdeoipHqo+YFgDCBfJTL5y4K4Qe2HTHk4STt5lriB00X9TQKfwuB0aA6ypADe+yG1fAeF7pmqIUeE/xkGUC74EZIo48TMUXR8dCuJ4iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pWKhyq7VAnIPKzmfoCybz/MajyTLj1sIsI1D8nlBNV8=; b=jRwqNx5pCUy8+as9YvSO9NL8KOg9CIt1BhQPIK0zaNY8cyqU6ddPIWv5Yn2nQPk2MZ+fjGGC7NfSRdpJV0tYvcho6yqbwYKdrLiPlOHmTenozg4RgfqBINo4gJEG0iAf/wH3SbSsFkRDEMeWK0I0quU2GcQOIVt6R+A5S2PzTfjWy1GoKZB+NUK45kf0vTXGetMTRW4G1b8UvfpVn0V6eUovfSU9WTqRBsChf25yB4FuUVni6tGn4kNiBtXgTs82OkNnVxerKpH+uHXIcfOmOU192h9EjwbecWoWrB6xT++tNZs/Y4s6a6yjkMI/WTcGxWmL5SSU5gbSm9XyW851vA== Received: from AS1P192MB1620.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:4a0::7) by GVXP192MB1784.EURP192.PROD.OUTLOOK.COM (2603:10a6:150:5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Wed, 18 Oct 2023 10:52:22 +0000 Received: from AS1P192MB1620.EURP192.PROD.OUTLOOK.COM ([fe80::f035:e341:1267:15e8]) by AS1P192MB1620.EURP192.PROD.OUTLOOK.COM ([fe80::f035:e341:1267:15e8%4]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 10:52:22 +0000 Message-ID: Subject: [PATCH v2] libstdc++: testsuite: Enhance codecvt_unicode with tests for length() From: Dimitrij Mijoski To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Date: Wed, 18 Oct 2023 12:52:20 +0200 In-Reply-To: References: User-Agent: Evolution 3.44.4-0ubuntu2 X-TMN: [da0U08T2op7gjZKGjzyTg8iF37vA3QN4] X-ClientProxiedBy: VI1PR0102CA0016.eurprd01.prod.exchangelabs.com (2603:10a6:802::29) To AS1P192MB1620.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:4a0::7) X-Microsoft-Original-Message-ID: <9d59a632b012f548736c2af678ca1aeba785ec9d.camel@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS1P192MB1620:EE_|GVXP192MB1784:EE_ X-MS-Office365-Filtering-Correlation-Id: b885e74a-dbe5-4154-9e05-08dbcfc84e63 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LvyXMKlIwBie69D9kDiBgAWz4tvwnz8qkE7e5q6NlhgK6EaWF+DxweCUrcE/+FwlezrmTnCXimAyg/sntXaohSzQgQ2d5g+HELwQO7hajSfuTZTM4l+fDe8dDsEg5mNvh6ZTLYkrQMZ1wNruQMoZihNjztvof+ZVEg0IStZYmFJZY0ixEJ0RE6FxFLviWMbvUikPx4CCt2succ+0CS9I7qBkv8eW0iEYsgEbvpmH7ZEh1hqA0aVzLLKFjvpX+3pRQSA1a6IPlS7TI5JSvTtDF5raee8DWPiKvDGoYBxKgRKWJj8p/APJU1cYOGK/kmVNrJ05UT6AJN4ZA4lF+EW2gz7Rih5uCA3p/Q0ZFvNAlxpzYWWvjqtyktVB2/+DBTK1/+IoyKo/DnV+gzC7HJklMzORS9RercKPp85usKwlRRa2OFyzY+6AZxSc5SrTGjI2D27l3jwffkgb7lxEX7RmqSi4RnQCwvHI5UqcTGvJ4k2HoteAbe0j4suJHNA9kjckO9yHtFoeZpkV5ZJsoZSMT8SUqcBCIDE3Ms/G0Z/FlDXFC55Uek2cgCJnZVzjc/bp X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?8hKGaNJo3Z9JdDNU10DMBb98LHy+?= =?utf-8?q?b6jf4X9Vo5bKjxP0Y/iKcWSS56yRqJvDTC48hJJtiQ/2yoz/bxzJXZolyH26hUOs8?= =?utf-8?q?j+g6zWC+4djFW+QRWivyaDJArzTBemx02QAjfarNd9F77u9C9Df1gZ6HDssZ9k/K4?= =?utf-8?q?+d4axkCcylvVigztDKP73s/wcDR/zT9ZkRfx6kbSDyjqNo3FsG+7O+aerBcxbbPi+?= =?utf-8?q?gr2gl0byM2kanSVHJwsmBe2eQ/cXiZsAJhQ0mOJVafLaRmj62+8tGhCre9muckU9P?= =?utf-8?q?8+GTpeyzyjBSp2EuZ455QMP4BC/gOxv+SiL460j+U97LLq/sKLu2d7sdsOqSGGVXm?= =?utf-8?q?Ny1FsmqotTAocI99n/E5LIuvX0E0ACNd8+XVqBE1bWpEkboHWj3mZ7SuWe5wP3t/s?= =?utf-8?q?IJ3Dx0JUlybs5DOsL2xUKuJ8N5ww/c4j2MHzAcoXFxWW92boHpvSYYrflwJdP8w+5?= =?utf-8?q?Dqcd+TnTfLcwNbXd8CoPWE1Dz+XH2Bc9VnWTuKRucF8BIWWn0rGh3u6xvt1br+vkr?= =?utf-8?q?CE4hqw2AQKdLVpDAQS9fq1LRZ/vdjJWnGOawRuEElMuojdzxi/mmMMXNVCh3GLOEf?= =?utf-8?q?FufC0YE25rMezuaDMA9xP3ZsPYW43j0u79sKgpL9EXIXpEDc0MIlF4rAoQbHF6NA0?= =?utf-8?q?7UAK8uUVcogji7adKGVqORyItdZO+45KONrts3Jq7Q6augvSmKXZhpi/M6dEpTLmb?= =?utf-8?q?/7vUlZW1+F8KtGHOCHwbG+6dbzUZgD8rn27HrNlbsWiwylFot/KgVFM1OvqosENji?= =?utf-8?q?ORXhkf+Tsj2GwgVV1TuCCYEyYgqMyKemlaQmkr+VFAZV1CFSAA15Tt39+85zzaglQ?= =?utf-8?q?3wq73d++fQe70m2ofrurLLlxRJM8RI+K6Yhpmq5wXDTt7v87FZ5LCIdjt7W36Z9f+?= =?utf-8?q?pqRmPYCgRABQb8aK0U1FJXZg7eAA2gOSRfjcEaP8k7ezVqymD9mPARkPerTbYfkrv?= =?utf-8?q?0p5Sa7KkU92oCiineFdIpglm+mpVmc27jwY63DpgBVudg20CINpSQLIetcZ29MDUi?= =?utf-8?q?j/vpE+FXJtATql8594q/XUsx5EL60oyllUCpT0ssEXI9fVvsgIQXRjNInwceoPACG?= =?utf-8?q?aWYnahmSAycNvSb7atPky3bd5GtYdN5e/zXI86UaHVuyJxadE9TBJOXL163AsB3ZH?= =?utf-8?q?NIN+XFvq05gFF2O9uA2kvh9/0UD1UAGfsFKHn9LA=3D=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-fb43a.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: b885e74a-dbe5-4154-9e05-08dbcfc84e63 X-MS-Exchange-CrossTenant-AuthSource: AS1P192MB1620.EURP192.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 10:52:22.2172 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP192MB1784 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780048868540105563 X-GMAIL-MSGID: 1780096125788768249 We can test codecvt::length() with the same data that we test codecvt::in(). For each call of in() we add another call to length(). Some additional small cosmentic changes are applied. libstdc++-v3/ChangeLog: * testsuite/22_locale/codecvt/codecvt_unicode.h: Test length() --- .../22_locale/codecvt/codecvt_unicode.h | 123 ++++++++++++++++-- 1 file changed, 110 insertions(+), 13 deletions(-) diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h index d3ae42fac..42270c50f 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h @@ -17,7 +17,6 @@ #include #include -#include #include struct test_offsets_ok @@ -79,6 +78,11 @@ utf8_to_utf32_in_ok (const std::codecvt &cvt) VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } for (auto t : offsets) @@ -99,6 +103,11 @@ utf8_to_utf32_in_ok (const std::codecvt &cvt) VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, array_size (out)); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } } @@ -163,6 +172,11 @@ utf8_to_utf32_in_partial (const std::codecvt &cvt) == 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); } } @@ -303,6 +317,11 @@ utf8_to_utf32_in_error (const std::codecvt &cvt) if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); + in[t.replace_pos] = old_char; } } @@ -334,7 +353,7 @@ utf32_to_utf8_out_ok (const std::codecvt &cvt) VERIFY (char_traits::length (in) == 4); VERIFY (char_traits::length (exp) == 10); - const test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {4, 10}}; + test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {4, 10}}; for (auto t : offsets) { ExternT out[array_size (exp) - 1] = {}; @@ -374,7 +393,7 @@ utf32_to_utf8_out_partial (const std::codecvt &cvt) VERIFY (char_traits::length (in) == 4); VERIFY (char_traits::length (exp) == 10); - const test_offsets_partial offsets[] = { + test_offsets_partial offsets[] = { {1, 0, 0, 0}, // no space for first CP {2, 1, 1, 1}, // no space for second CP @@ -528,6 +547,11 @@ utf8_to_utf16_in_ok (const std::codecvt &cvt) VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } for (auto t : offsets) @@ -548,6 +572,11 @@ utf8_to_utf16_in_ok (const std::codecvt &cvt) VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, array_size (out)); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } } @@ -617,6 +646,11 @@ utf8_to_utf16_in_partial (const std::codecvt &cvt) == 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); } } @@ -757,6 +791,11 @@ utf8_to_utf16_in_error (const std::codecvt &cvt) if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); + in[t.replace_pos] = old_char; } } @@ -788,7 +827,7 @@ utf16_to_utf8_out_ok (const std::codecvt &cvt) VERIFY (char_traits::length (in) == 5); VERIFY (char_traits::length (exp) == 10); - const test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {5, 10}}; + test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {5, 10}}; for (auto t : offsets) { ExternT out[array_size (exp) - 1] = {}; @@ -828,7 +867,7 @@ utf16_to_utf8_out_partial (const std::codecvt &cvt) VERIFY (char_traits::length (in) == 5); VERIFY (char_traits::length (exp) == 10); - const test_offsets_partial offsets[] = { + test_offsets_partial offsets[] = { {1, 0, 0, 0}, // no space for first CP {2, 1, 1, 1}, // no space for second CP @@ -1005,6 +1044,11 @@ utf8_to_ucs2_in_ok (const std::codecvt &cvt) VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } for (auto t : offsets) @@ -1025,6 +1069,11 @@ utf8_to_ucs2_in_ok (const std::codecvt &cvt) VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, array_size (out)); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } } @@ -1081,6 +1130,11 @@ utf8_to_ucs2_in_partial (const std::codecvt &cvt) == 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); } } @@ -1231,6 +1285,11 @@ utf8_to_ucs2_in_error (const std::codecvt &cvt) if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); + in[t.replace_pos] = old_char; } } @@ -1262,7 +1321,7 @@ ucs2_to_utf8_out_ok (const std::codecvt &cvt) VERIFY (char_traits::length (in) == 3); VERIFY (char_traits::length (exp) == 6); - const test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}}; + test_offsets_ok offsets[] = {{0, 0}, {1, 1}, {2, 3}, {3, 6}}; for (auto t : offsets) { ExternT out[array_size (exp) - 1] = {}; @@ -1302,7 +1361,7 @@ ucs2_to_utf8_out_partial (const std::codecvt &cvt) VERIFY (char_traits::length (in) == 3); VERIFY (char_traits::length (exp) == 6); - const test_offsets_partial offsets[] = { + test_offsets_partial offsets[] = { {1, 0, 0, 0}, // no space for first CP {2, 1, 1, 1}, // no space for second CP @@ -1499,6 +1558,11 @@ utf16_to_utf32_in_ok (const std::codecvt &cvt, VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } for (auto t : offsets) @@ -1519,6 +1583,11 @@ utf16_to_utf32_in_ok (const std::codecvt &cvt, VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, array_size (out)); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } } @@ -1535,7 +1604,6 @@ utf16_to_utf32_in_partial (const std::codecvt &cvt, char in[array_size (input) * 2]; InternT exp[array_size (expected)]; - auto in_iter = begin (in); utf16_to_bytes (begin (input), end (input), begin (in), endianess); copy (begin (expected), end (expected), begin (exp)); @@ -1582,6 +1650,11 @@ utf16_to_utf32_in_partial (const std::codecvt &cvt, == 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); } } @@ -1656,6 +1729,11 @@ utf16_to_utf32_in_error (const std::codecvt &cvt, if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); + input[t.replace_pos] = old_char; } } @@ -1676,7 +1754,7 @@ utf32_to_utf16_out_ok (const std::codecvt &cvt, copy (begin (input), end (input), begin (in)); utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess); - const test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 10}}; + test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 10}}; for (auto t : offsets) { char out[array_size (exp) - 2] = {}; @@ -1714,7 +1792,7 @@ utf32_to_utf16_out_partial (const std::codecvt &cvt, copy (begin (input), end (input), begin (in)); utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess); - const test_offsets_partial offsets[] = { + test_offsets_partial offsets[] = { {1, 0, 0, 0}, // no space for first CP {1, 1, 0, 0}, // no space for first CP @@ -1858,6 +1936,11 @@ utf16_to_ucs2_in_ok (const std::codecvt &cvt, VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } for (auto t : offsets) @@ -1878,6 +1961,11 @@ utf16_to_ucs2_in_ok (const std::codecvt &cvt, VERIFY (char_traits::compare (out, exp, t.out_size) == 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, array_size (out)); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.in_size); } } @@ -1894,7 +1982,6 @@ utf16_to_ucs2_in_partial (const std::codecvt &cvt, char in[array_size (input) * 2]; InternT exp[array_size (expected)]; - auto in_iter = begin (in); utf16_to_bytes (begin (input), end (input), begin (in), endianess); copy (begin (expected), end (expected), begin (exp)); @@ -1933,6 +2020,11 @@ utf16_to_ucs2_in_partial (const std::codecvt &cvt, == 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); } } @@ -2018,6 +2110,11 @@ utf16_to_ucs2_in_error (const std::codecvt &cvt, if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] == 0); + state = {}; + auto len = cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >= 0); + VERIFY (static_cast (len) == t.expected_in_next); + input[t.replace_pos] = old_char; } } @@ -2038,7 +2135,7 @@ ucs2_to_utf16_out_ok (const std::codecvt &cvt, copy (begin (input), end (input), begin (in)); utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess); - const test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}}; + test_offsets_ok offsets[] = {{0, 0}, {1, 2}, {2, 4}, {3, 6}}; for (auto t : offsets) { char out[array_size (exp) - 2] = {}; @@ -2076,7 +2173,7 @@ ucs2_to_utf16_out_partial (const std::codecvt &cvt, copy (begin (input), end (input), begin (in)); utf16_to_bytes (begin (expected), end (expected), begin (exp), endianess); - const test_offsets_partial offsets[] = { + test_offsets_partial offsets[] = { {1, 0, 0, 0}, // no space for first CP {1, 1, 0, 0}, // no space for first CP