From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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?B?OGhLR2FOSm8zWjlKZEROVTEwRE1CYjk4TEh5K2I2amY0WDlWbzViS2p4UDBZ?= =?utf-8?B?L2lLY1dTUzU2eVJxSnZEVEM0OGhKSnRpUS8yeW96L2J4ekpYWm9seUgyNmhV?= =?utf-8?B?T3M4aitnNnpXQys0ZGpGVytRUldpdnlhREpBcnpUQmVteDAyUUFqZmFyTmQ5?= =?utf-8?B?Rjc3dTlDOURmMWdaNkhEc3NaOWsvSzQrZDRheGtDY3lsdlZpZ3p0REtQNzNz?= =?utf-8?B?L3djRFIvelQ5WmtSZng2a2JTRHlqcU5vM0ZzRys3TythZXJCY3hiYlBpK2dy?= =?utf-8?B?MmdsMGJ5TTJrYW5TVkhKd3NtQmUyZVEvY1hpWnNBSmhRMG1PSlZhZkxhUm1q?= =?utf-8?B?NjIrOHRHaENyZTltdWNrVTlQOCtHVHBleXp5akJTcDJFdVo0NTVRTVA0QkMv?= =?utf-8?B?Z094ditTaUw0NjBqK1U5N0xMcS9zS0x1MmQ3c2RzT3FTR0dWWG1OeTFGc21x?= =?utf-8?B?b3RUQW9jSTk5bi9FNUxJdXZYMEUwQUNOZDgrWFZxQkUxYldwRWtib0hXajNt?= =?utf-8?B?WjdTdVdlNXdQM3Qvc0lKM0R4MEpVbHliczVET3NMMnhVS3VKOE41d3cvYzRq?= =?utf-8?B?Mk1IekFjb1hGeFdXOTJib0hwdlNZWXJmbHdKZFA4dys1RHFjZCtUblRmTGN3?= =?utf-8?B?TmJYZDhDb1BXRTFEeitYSDJCYzlWbldUdUtSdWNGOEJJV1duMHJHaDN1Nnh2?= =?utf-8?B?dDFicit2a3JDRTRocXcyQVFLZExWcERBUVM5ZnExTFJaL3ZkakpXbkdPYXdS?= =?utf-8?B?dUVFbE11b2pkenhpL21tTU1YTlZDaDNHTE9FZkZ1ZkMwWUUyNXJNZXp1YURN?= =?utf-8?B?QTl4UDNac1BZVzQzajB1NzlzS2dwTDlFWElYcEVEYzBNSWxGNHJBb1FiSEY2?= =?utf-8?B?TkEwN1VBSzh1VVZjb2dqaTdhZEtHVnFPUnlJdGRaTys0NUtPTnJ0czNKcTdR?= =?utf-8?B?NmF1Z3ZTbUtYWmhwaS9NNmRFcFRMbWIvN3ZVbFpXMStGOEt0R0hPQ0h3Ykcr?= =?utf-8?B?NmRielVaZ0Q4cm4yN0hyTmxic1dpd3lsRm90L0tnVkZNMU92cW9zRU5qaU9S?= =?utf-8?B?WGhrZitUc2oyR3dnVlYxVHVDQ1lFeVlncU15S2VtbGFRbWtyK1ZGQVpWMUNG?= =?utf-8?B?U0FBMTVUdDM5Kzg1enphZ2xRM3dxNzNkKytmUWU3MG0yb2ZydXJMTGx4UkpN?= =?utf-8?B?OFJJK0s2WWhwbXE1d1hEVHQ3djg3Rlo1TENJZGp0N1czNlo5ZitwcVJtUFlD?= =?utf-8?B?Z1JBQlFiOGFLMFUxRkpYWmc3ZUFBMmdPU1JmamNFYVA4azdlelZxeW1EOW1Q?= =?utf-8?B?QVJrUGVyVGJZZmtydjBwNVNhN0trVTkyb0NpaW5lRmRJcGdsbSttcFZtYzI3?= =?utf-8?B?andZNjNEcGdCVnVkZzIwQ0lOcFNRTElldGNaMjlNRFVpai92cEUrRlhKdEFU?= =?utf-8?B?cWw4NTk0cS9YVXN4NUVMNjBveWxsVUNwVDBzc0VYSTlmVnZzZ0lRWFJqTklu?= =?utf-8?B?d2Nlb1BBQ0dhV1luYWhtU0F5Y052U2I3YXRQa3kzYmQ1R3RZZE41ZS96WEk4?= =?utf-8?B?NlVhSFZ1eUp4YWRFOVRCSk9YTDE2M0FzQjNaSE5JTitYRnZxMDVnRkYyTzl1?= =?utf-8?B?QTJrdmg5LzBVRDFVQUdmc0ZLSG45TEE9PQ==?= 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 List-Id: 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/l= ibstdc++-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 @@ =20 #include #include -#include #include =20 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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } =20 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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, array_size (out)= ); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } } =20 @@ -163,6 +172,11 @@ utf8_to_utf32_in_partial (const std::codecvt &cvt) =3D=3D 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); } } =20 @@ -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] =3D=3D 0); =20 + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); + in[t.replace_pos] =3D old_char; } } @@ -334,7 +353,7 @@ utf32_to_utf8_out_ok (const std::codecvt &cvt) VERIFY (char_traits::length (in) =3D=3D 4); VERIFY (char_traits::length (exp) =3D=3D 10); =20 - const test_offsets_ok offsets[] =3D {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {4,= 10}}; + test_offsets_ok offsets[] =3D {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {4, 10}}; for (auto t : offsets) { ExternT out[array_size (exp) - 1] =3D {}; @@ -374,7 +393,7 @@ utf32_to_utf8_out_partial (const std::codecvt &cvt) VERIFY (char_traits::length (in) =3D=3D 4); VERIFY (char_traits::length (exp) =3D=3D 10); =20 - const test_offsets_partial offsets[] =3D { + test_offsets_partial offsets[] =3D { {1, 0, 0, 0}, // no space for first CP =20 {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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } =20 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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, array_size (out)= ); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } } =20 @@ -617,6 +646,11 @@ utf8_to_utf16_in_partial (const std::codecvt &cvt) =3D=3D 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); } } =20 @@ -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] =3D=3D 0); =20 + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); + in[t.replace_pos] =3D old_char; } } @@ -788,7 +827,7 @@ utf16_to_utf8_out_ok (const std::codecvt &cvt) VERIFY (char_traits::length (in) =3D=3D 5); VERIFY (char_traits::length (exp) =3D=3D 10); =20 - const test_offsets_ok offsets[] =3D {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {5,= 10}}; + test_offsets_ok offsets[] =3D {{0, 0}, {1, 1}, {2, 3}, {3, 6}, {5, 10}}; for (auto t : offsets) { ExternT out[array_size (exp) - 1] =3D {}; @@ -828,7 +867,7 @@ utf16_to_utf8_out_partial (const std::codecvt &cvt) VERIFY (char_traits::length (in) =3D=3D 5); VERIFY (char_traits::length (exp) =3D=3D 10); =20 - const test_offsets_partial offsets[] =3D { + test_offsets_partial offsets[] =3D { {1, 0, 0, 0}, // no space for first CP =20 {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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } =20 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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, array_size (out)= ); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } } =20 @@ -1081,6 +1130,11 @@ utf8_to_ucs2_in_partial (const std::codecvt &cvt) =3D=3D 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); } } =20 @@ -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] =3D=3D 0); =20 + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); + in[t.replace_pos] =3D old_char; } } @@ -1262,7 +1321,7 @@ ucs2_to_utf8_out_ok (const std::codecvt &cvt) VERIFY (char_traits::length (in) =3D=3D 3); VERIFY (char_traits::length (exp) =3D=3D 6); =20 - const test_offsets_ok offsets[] =3D {{0, 0}, {1, 1}, {2, 3}, {3, 6}}; + test_offsets_ok offsets[] =3D {{0, 0}, {1, 1}, {2, 3}, {3, 6}}; for (auto t : offsets) { ExternT out[array_size (exp) - 1] =3D {}; @@ -1302,7 +1361,7 @@ ucs2_to_utf8_out_partial (const std::codecvt &cvt) VERIFY (char_traits::length (in) =3D=3D 3); VERIFY (char_traits::length (exp) =3D=3D 6); =20 - const test_offsets_partial offsets[] =3D { + test_offsets_partial offsets[] =3D { {1, 0, 0, 0}, // no space for first CP =20 {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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } =20 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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, array_size (out)= ); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } } =20 @@ -1535,7 +1604,6 @@ utf16_to_utf32_in_partial (const std::codecvt &cvt, =20 char in[array_size (input) * 2]; InternT exp[array_size (expected)]; - auto in_iter =3D begin (in); utf16_to_bytes (begin (input), end (input), begin (in), endianess); copy (begin (expected), end (expected), begin (exp)); =20 @@ -1582,6 +1650,11 @@ utf16_to_utf32_in_partial (const std::codecvt &cvt, =3D=3D 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); } } =20 @@ -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] =3D=3D 0); =20 + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); + input[t.replace_pos] =3D 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= ); =20 - const test_offsets_ok offsets[] =3D {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4,= 10}}; + test_offsets_ok offsets[] =3D {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 10}}; for (auto t : offsets) { char out[array_size (exp) - 2] =3D {}; @@ -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= ); =20 - const test_offsets_partial offsets[] =3D { + test_offsets_partial offsets[] =3D { {1, 0, 0, 0}, // no space for first CP {1, 1, 0, 0}, // no space for first CP =20 @@ -1858,6 +1936,11 @@ utf16_to_ucs2_in_ok (const std::codecvt &cvt, VERIFY (char_traits::compare (out, exp, t.out_size) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } =20 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) =3D=3D = 0); if (t.out_size < array_size (out)) VERIFY (out[t.out_size] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, array_size (out)= ); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.in_size); } } =20 @@ -1894,7 +1982,6 @@ utf16_to_ucs2_in_partial (const std::codecvt &cvt, =20 char in[array_size (input) * 2]; InternT exp[array_size (expected)]; - auto in_iter =3D begin (in); utf16_to_bytes (begin (input), end (input), begin (in), endianess); copy (begin (expected), end (expected), begin (exp)); =20 @@ -1933,6 +2020,11 @@ utf16_to_ucs2_in_partial (const std::codecvt &cvt, =3D=3D 0); if (t.expected_out_next < array_size (out)) VERIFY (out[t.expected_out_next] =3D=3D 0); + + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); } } =20 @@ -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] =3D=3D 0); =20 + state =3D {}; + auto len =3D cvt.length (state, in, in + t.in_size, t.out_size); + VERIFY (len >=3D 0); + VERIFY (static_cast (len) =3D=3D t.expected_in_next); + input[t.replace_pos] =3D 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= ); =20 - const test_offsets_ok offsets[] =3D {{0, 0}, {1, 2}, {2, 4}, {3, 6}}; + test_offsets_ok offsets[] =3D {{0, 0}, {1, 2}, {2, 4}, {3, 6}}; for (auto t : offsets) { char out[array_size (exp) - 2] =3D {}; @@ -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= ); =20 - const test_offsets_partial offsets[] =3D { + test_offsets_partial offsets[] =3D { {1, 0, 0, 0}, // no space for first CP {1, 1, 0, 0}, // no space for first CP =20 --=20 2.34.1