From patchwork Tue Oct 17 22:50:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitrij Mijoski X-Patchwork-Id: 154602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4466522vqb; Tue, 17 Oct 2023 16:54:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYQ5tjAfoZQ8HE9C+qSb23WodxC2zoKg12Qt+rNKtxQfXv8LPv0E0h/55I50dadf/mJlW6 X-Received: by 2002:a05:6214:224c:b0:65a:fc2a:c2ab with SMTP id c12-20020a056214224c00b0065afc2ac2abmr5482411qvc.49.1697586887759; Tue, 17 Oct 2023 16:54:47 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1697586887; cv=pass; d=google.com; s=arc-20160816; b=bCanqzCGCOqdtsgTqZ8HUhiNe1y5UC3yE8wHEx97xzG6aCECNsOsQeX440ILIYJIlk mBm2EoqQSt5RA0JyMym4IlKF0ydrZpvkfDs3lJ+xbhuqAk+Wr9jgumGHuI9WC/5R7edB R/wzKOJUAfO0w3ONvnoUkYq4a6yCWTnaTBrCRJrC+ZKEHq6RQhY2k3Jy4JXJa69K7KHG 88puRTMdyATroZcpvlDgnW58gw+k/g2EP1sDd5GJW4LmEFo1tLWJDCLRvXEE+GxKIWok dXGsRqBvoEH4Bcfnh1tmglhPS1HN6O/m/0JhloADY6/Qk+LcW3FpNKNHr06sdsv9SBdv Bk2g== 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:date:to:from:subject:message-id :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=pBLZ/RuL0pMG+2SzZs1ZNJt8+P0z+nPsDDN9XYpRyNI=; fh=+uLa3m5dEsZWyE738VC4UtcvjxY1kYREGLuytVVwtpk=; b=kbCpfW3YDi0xPubcYT354xIgg07AK0qleX6HhjZeAe/7vu9FnmMyQ1jKfA/I6in2y+ HVy9NZXKWqvIPDH1FHd1A+FoGTYDYt297tnM66M4kGXd/LWUgNdf4y9ddMu/mF/GyYrL iNLgiWW6Li3298Jf71F5SP1Ltt2E/f+2Fm0dLTn8IDfNxRT7BJVe+UIs/dPpcjzZLl3B SozSnm+qkw89RhwCpYFFlL3YzuCbcRrHSJQbBxwN7/42ltl3o7dTXkIWvaGKRxX+DQGH HAXNL8i23+as8rlWau0cnZfjJlelUMHRldAnAWaautQtgfKgRfHTZvgb00nam4Kv0+PO Z6ag== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@hotmail.com header.s=selector1 header.b=Aa3CIn05; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id jy9-20020a0562142b4900b0066d12fe2089si1815034qvb.608.2023.10.17.16.54.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 16:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@hotmail.com header.s=selector1 header.b=Aa3CIn05; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 512383857438 for ; Tue, 17 Oct 2023 22:51:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2096.outbound.protection.outlook.com [40.92.58.96]) by sourceware.org (Postfix) with ESMTPS id 1F33D3858D33; Tue, 17 Oct 2023 22:50:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F33D3858D33 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 1F33D3858D33 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.92.58.96 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697583046; cv=pass; b=KrG70Ik+0AlAfCesPaqJnNT6WjG1mNnEpnSy2z3SYJbN+dv6mGGoCLmioYgyHyfJFAgUmkAVpwOywe3uLGEcFqMpb0TfSxnebn2uJo9U4tf4S1F9e5iD1BmVCICouyE/GLwxuSJs9JA63BF6wFCzUM83ayNPOm2aUW7k28uYrUQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697583046; c=relaxed/simple; bh=DQ24qaOJphFe9yEUugrluBXFc6K7UaV8p4Qcy1xCO4s=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=DHFnB7YhUkAiWXUpbrtUQgzI0cPHB2Q0W4T0ynSEV+DAk1mGwy6suJ2hYWyXLTPxVv+Rm7Rz5ry6zqeLw0qqKgZohjoKzkbbjjlbYuAeVorQBclPlmh2Dgp0Ju5kjTlcSkrWtCAl9KvOc3zIIv43i898ZKi3K/ncMsq3l/gDjQA= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R8h/ZZTUAYekz9zIkSpMsi3lsJATEJBkzpdkAqd+upH7VnkQcZw2x/aieQRJDBRTGJE9K3nET8qOAZ9+lrVxTzFZoYqRJ94/fIunYDypREkvbDiWk3yWPp1KftfbgT13HDREtgiqBqqkHTHqtU7OeZfxHMFqwSfsCze/zqqYHt2xwpteMVDHFfqfDLEzR+3P7C5G94oIhSNntqRWHWWgkJ0e0jGpn9da9DYVt/mrdn54Lmfyb+deSrtbZnGGFg0NtUJfkGODxzQsk3n9Z8yjagfs7jeVCYb8rY170fKUf7r9N201Bxqzdd3iD7/NtkgF3RD8CmIJ40iGdWu13RDdMw== 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=pBLZ/RuL0pMG+2SzZs1ZNJt8+P0z+nPsDDN9XYpRyNI=; b=CvGVT4tjhc1v08wsNHFOLhxmRZ1vHLtBDCMZf2KPDv2giCKp5EOu1DsYwSljwzsG5GNgTisdLnYa2Vgll5qCf8bsi9RiJ3KCsu2CEPBP0cytIGJlNTMTHvoCP8cfMTOubk7/Dpd5JpR6lxSRt8kHqlVQ5WRa+bk5uEGxKifWBSV0jSTAVc/e02uWkrRC2SbzEkxjeQqNlNAcYjxJpb+BGdlMrDI7xdCdEsyRQ8/dTx4CUioxTSlaatOdETVmwMH+rcl9mNK/+BqPGpAMYTojJP28ri7t9nUHNqTz1c4/QZV30bbJH8ZgJLgWLizXJRV+XOCrg6m3Ko71E8Hx8mtPQA== 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=pBLZ/RuL0pMG+2SzZs1ZNJt8+P0z+nPsDDN9XYpRyNI=; b=Aa3CIn05w5KL350Dw1a/LoXKIIR5UqiqBrZxumVt5YLhp4UXLwrowncY3o0w5oEiyRfh7JitlKYhFimpF49mwBInHFMNsbUoZuNokW3E5qejkAn+OSw5lNdOb2iC1kh0p7KHTD/iS650MH15/Z2ZBV2JXuv6j8hXJtqP6jrqGbOnaz5HlCzIKOGmplJussKoMHBUlElvaqsJ5plX6VaaSIFRJCpZoUZmaNOIv2vM5b6ViFWR8QUWVx/t2n/V4mzYgbRMcyzupCkkqd2qkL8zsJX0cFla3uCz/RWj9FHxq6IAqHImI2gksMEupBvGZS7GN3Y2SxJl/VGyCdI+vBoEmw== Received: from AS1P192MB1620.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:4a0::7) by DB9P192MB1370.EURP192.PROD.OUTLOOK.COM (2603:10a6:10:293::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.34; Tue, 17 Oct 2023 22:50:42 +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; Tue, 17 Oct 2023 22:50:42 +0000 Message-ID: Subject: [PATCH] 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 00:50:40 +0200 User-Agent: Evolution 3.44.4-0ubuntu2 X-TMN: [yVnIB9STNclTLa/uLeelHxTnXMVa7SZS] X-ClientProxiedBy: VI1P194CA0041.EURP194.PROD.OUTLOOK.COM (2603:10a6:803:3c::30) To AS1P192MB1620.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:4a0::7) X-Microsoft-Original-Message-ID: <8361b170271d97cf9bca7b512bfb1b44f6b99b80.camel@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS1P192MB1620:EE_|DB9P192MB1370:EE_ X-MS-Office365-Filtering-Correlation-Id: e8c44737-1955-4c52-9fad-08dbcf637dc7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3WmVIns8ql0FEJEnDKZZIkn3MHz3o3zZ+MSXALXBAE3ZmnCRtr8hQhGlO0miEvAMVfVTQYaYXlNjK+HHgLdpzwpHhwJYHZsczyoP/yBbQfeir073wFLg8Xst7dRmPLufSVUPWp6WWt2rXM7BZMAHNVLY2uZdy4+tz7/9YNiEDUa07tVzO5jaxFg6RvFGuav3wvWtaknKwbevvgnR+bgNymh4pim4RamvlcfRvjZYNl9oZ9o/+Pry01fj8YLDuYX06uzGeGtay/kcMK2EmN4ll85WeYsveUQxkv/2vxMl7pIhYV3HLqJiiKs2arhWovtqjYQYrVvhZwTVp6GkZEZUBDmDcvZ3t7k3OUj6HL/lGOUi5nDBVTj9XJSLSbB2qCUcvmKYKGs06tp9w35bglDTbGzy64nxkm36HekYP+cxQMw6vXU78MwVBCz+Ckw8zi7eu6nC8o2Q2h+NRfdmnjnAUs9BTas+ufqlVb71faqkEF4ZjLMLawnwcSUqfJRCH6xny41mQaZ5zH8U3xbQkdawXhJq1BXF0nZJzJ0VAnSPPPA/EvHwLXQVIU8CUhQvefYm X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?218XJOxVmIXBj3IkwrIpuQLjGnSR?= =?utf-8?q?fyROEw1/AbMlN249NsSjYq4sks0jFb2ERjkhgiqV6GLzy1VXEN0lHD+DfLeSrn24S?= =?utf-8?q?DcBWoxSfzbLnCb0VhnHXMvmoe8wADU1sqOoPMtIXrRzMPhEZbYOTMPXXS8BZu5vif?= =?utf-8?q?gzL1xbAiYu7Ms59qErYFTDsufoHawUluC/3zCbVd0LK4e95TA2Y4bCbDhf7d9S+aA?= =?utf-8?q?zWphHmYtyjaq8i8lRS0s0lB2nhbqEanYCnxtzIzna+vz8RlFebtVp/mAtmJ5Hppy1?= =?utf-8?q?9Lor1rNaobzNCYnuSQ4biUYwuwIaz53XgnFSsd+fICN87ATCNKwzEpfYIr9SZ1+mz?= =?utf-8?q?32WODQfkrEUZbomN+ajoHyLVJnWOvP8NB3dIGQGsfrMccKJn+eTtaJpTSR2o14olM?= =?utf-8?q?Fl/YxiGazTVPUvah3fe7sZVGmqqZpABQ+0siJj+n+WrU3HqMuEC9gXqEEsed1zZXz?= =?utf-8?q?eCJrhc+CVNMjiqmhwc1nW4gUpGeD4g8AwkC5VOU8/3CXvLO1YLD+jbFdjQ94gtdTO?= =?utf-8?q?nM9esKVDhxIKASrKKxElqq2w8PHbeu1TYDpxkw05QC3Cfiu10Q5BJ8HqZfnEGyRzk?= =?utf-8?q?kgS7YoBMN5hDdcHG2Pb6RIwWtBdL401aBCNC5cICiKSdmNsZZe2aDJiE31PiqONDJ?= =?utf-8?q?6tZPsUqZm56+Ht1B+7qKZ8c2/z14xVKTE7x7fIejom1/hvtAeAR97S+dOzG1aiJ1K?= =?utf-8?q?A2xuBbyn3n0pWw/P/5XuRFRbnUQdjfpgZn3MnFTBx03v5DA22eBsmKzuL9boZE083?= =?utf-8?q?W3tisP1a5qg3PQeHvg0L3NWVozn7ZPB45qM4LmTmGum3udQPy+RTJCc88osGiyloa?= =?utf-8?q?/di1LdtrYQhuSQ5NAjxcdsOs8JDPBvYZWpJ1sF4AYfzx2T/5ZEJD9tt1HTF/GpCMx?= =?utf-8?q?3y5oGzNmvB8TsyDlnPjuZgmh3V9q6JMKi+QlHNBkTC0nEk3AJ4TVucFnxmzXRHIYx?= =?utf-8?q?N+VRq3aQm5Gro7RqEUL2DJQby5uMKAcIoIO2kDhvPgraHtdmla878yXO3LiT9XYkw?= =?utf-8?q?M/dtoLEnWPrqpNLH7c3eLmAVSCRuXugDsbvvIesyobii+qymNTajIYDuLbasDLAKn?= =?utf-8?q?kv7Xh3TePW580Ulq/QRkh8/wjuhBAy6tSN1X6+4qO+cJVgmxTrdtIfsKW5MwqAMc5?= =?utf-8?q?s14UL/8AZRKS/4tugMnK9vzOZSqNtQ95wUrc2DXw=3D=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-fb43a.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: e8c44737-1955-4c52-9fad-08dbcf637dc7 X-MS-Exchange-CrossTenant-AuthSource: AS1P192MB1620.EURP192.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 22:50:42.5142 (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: DB9P192MB1370 X-Spam-Status: No, score=-9.2 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_NONE, 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: 1780048868540105563 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 | 103 +++++++++++++++--- 1 file changed, 90 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..b3c257ec2 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,10 @@ 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 == t.in_size); } for (auto t : offsets) @@ -99,6 +102,10 @@ 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 == t.in_size); } } @@ -163,6 +170,10 @@ 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 == t.expected_in_next); } } @@ -303,6 +314,10 @@ 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 == t.expected_in_next); + in[t.replace_pos] = old_char; } } @@ -334,7 +349,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 +389,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 +543,10 @@ 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 == t.in_size); } for (auto t : offsets) @@ -548,6 +567,10 @@ 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 == t.in_size); } } @@ -617,6 +640,10 @@ 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 == t.expected_in_next); } } @@ -757,6 +784,10 @@ 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 == t.expected_in_next); + in[t.replace_pos] = old_char; } } @@ -788,7 +819,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 +859,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 +1036,10 @@ 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 == t.in_size); } for (auto t : offsets) @@ -1025,6 +1060,10 @@ 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 == t.in_size); } } @@ -1081,6 +1120,10 @@ 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 == t.expected_in_next); } } @@ -1231,6 +1274,10 @@ 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 == t.expected_in_next); + in[t.replace_pos] = old_char; } } @@ -1262,7 +1309,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 +1349,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 +1546,10 @@ 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 == t.in_size); } for (auto t : offsets) @@ -1519,6 +1570,10 @@ 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 == t.in_size); } } @@ -1535,7 +1590,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 +1636,10 @@ 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 == t.expected_in_next); } } @@ -1656,6 +1714,10 @@ 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 == t.expected_in_next); + input[t.replace_pos] = old_char; } } @@ -1676,7 +1738,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 +1776,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 +1920,10 @@ 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 == t.in_size); } for (auto t : offsets) @@ -1878,6 +1944,10 @@ 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 == t.in_size); } } @@ -1894,7 +1964,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 +2002,10 @@ 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 == t.expected_in_next); } } @@ -2018,6 +2091,10 @@ 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 == t.expected_in_next); + input[t.replace_pos] = old_char; } } @@ -2038,7 +2115,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 +2153,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