From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id D14183858C27; Tue, 17 Jan 2023 21:34:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D14183858C27 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x535.google.com with SMTP id b4so27503858edf.0; Tue, 17 Jan 2023 13:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UX6ryfBRiYccpcOyyeBFy0m3jTIH0Ooiua/Z8eiooko=; b=hVia54HYZlAkE3WUEtxOQZoeTNx6KHopq69mYiYnqf6TuPLMGuVn1scXlguzX21e8S R+KMRn5vwBscr8tJmNQyCtl2uU8XEztfFMGA4aXeHUQIpSxWwFl96XeYXAZrzdwmX279 OXZK1YWdELe+Bs7B0VvHikbBSioLct0fY5Ag3EAsJD8X7vtDJKCcVfuhcRxeEcRLF1th p6UFoJRNm1ESx8TOQmPmLLUIqQ/LcVGPXsq8N9gGg+n9mcj+3SljD6lC8R5UQrxmnBT6 LyqYxHNjNteInTzRRNl50w2LkVj5AWK2agx923nQVPdG1QnYVoWgTZcuK/+ct8h+JMjo UcDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UX6ryfBRiYccpcOyyeBFy0m3jTIH0Ooiua/Z8eiooko=; b=4h67ETGRzvh9lBX9eoHZqMlT1zX/EhS7ttanORf1r+v+o/xIV50cRAM48DG+7t+HqK h2/uvefg3pTVx5vYndzFPtRJHotpkD2Y6QYpd2RVcA2boilYWnRc7dIE2cr+0Bi9sTVY n50jNo75zk0DXPFeAXRVOLCxjYqVcOY946IHNVuEOxQCT3h8KANG5fE3bhZf8Dpgq3Il zRUN0vx+pz18m0KbHhjR26CYk26EAGmBXXW0hLFDh5+8DLObD7Pn0kGFRrTlXGMf3XGL Sl5jzXPP2pN6iGGZ0S0lnOATScR1/Rg9DZg86XNdc7X+FTZDsR8rGHUMXv39j+akcEvN S2cw== X-Gm-Message-State: AFqh2ko3xskMYyGVC0PReHqE1VQ/aYAo0URTIq4CDkx6w8dw51R+8GLk OPe0xuuFXeE03OtqQXPJXARhLZ7G+uRfFEP6MYM= X-Google-Smtp-Source: AMrXdXuFvTc5YUunmHHej6nXs5dMbQn+hRpNJa/eJpmZN0xug780xGIatjbvGHj3Adsyc61ias7XC3mYsSpGCemECPg= X-Received: by 2002:a05:6402:5419:b0:49e:ea6:233e with SMTP id ev25-20020a056402541900b0049e0ea6233emr473514edb.301.1673991281475; Tue, 17 Jan 2023 13:34:41 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Tue, 17 Jan 2023 21:34:29 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: testsuite: Simplify codecvt_unicode To: Dimitrij Mijoski Cc: gcc-patches , "libstdc++" Content-Type: multipart/alternative; boundary="000000000000b0842605f27c7799" X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,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 List-Id: --000000000000b0842605f27c7799 Content-Type: text/plain; charset="UTF-8" On Tue, 17 Jan 2023, 21:12 Dimitrij Mijoski via Libstdc++, < libstdc++@gcc.gnu.org> wrote: > Stop using unique_ptr, create some objects directly. > Thanks, I thought about suggesting this, but decided it was good enough. But I'm glad to see the simplifications :-) I'll get this committed. > libstdc++-v3/ChangeLog: > > * testsuite/22_locale/codecvt/codecvt_unicode.cc: Simplify. > * testsuite/22_locale/codecvt/codecvt_unicode.h: Simplify. > * testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: Simplify. > --- > .../22_locale/codecvt/codecvt_unicode.cc | 18 ++++++++++-------- > .../22_locale/codecvt/codecvt_unicode.h | 9 +-------- > .../codecvt/codecvt_unicode_wchar_t.cc | 12 ++++++------ > 3 files changed, 17 insertions(+), 22 deletions(-) > > diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc > b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc > index ae4b6c896..3d7393e4a 100644 > --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc > +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.cc > @@ -29,11 +29,12 @@ test_utf8_utf32_codecvts () > using codecvt_c32 = codecvt; > auto loc_c = locale::classic (); > VERIFY (has_facet (loc_c)); > + > auto &cvt = use_facet (loc_c); > test_utf8_utf32_codecvts (cvt); > > - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); > - test_utf8_utf32_codecvts (*cvt_ptr); > + auto cvt2 = codecvt_utf8 (); > + test_utf8_utf32_codecvts (cvt2); > } > > void > @@ -42,21 +43,22 @@ test_utf8_utf16_codecvts () > using codecvt_c16 = codecvt; > auto loc_c = locale::classic (); > VERIFY (has_facet (loc_c)); > + > auto &cvt = use_facet (loc_c); > test_utf8_utf16_cvts (cvt); > > - auto cvt_ptr = to_unique_ptr (new codecvt_utf8_utf16 ()); > - test_utf8_utf16_cvts (*cvt_ptr); > + auto cvt2 = codecvt_utf8_utf16 (); > + test_utf8_utf16_cvts (cvt2); > > - auto cvt_ptr2 = to_unique_ptr (new codecvt_utf8_utf16 ()); > - test_utf8_utf16_cvts (*cvt_ptr2); > + auto cvt3 = codecvt_utf8_utf16 (); > + test_utf8_utf16_cvts (cvt3); > } > > void > test_utf8_ucs2_codecvts () > { > - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); > - test_utf8_ucs2_cvts (*cvt_ptr); > + auto cvt = codecvt_utf8 (); > + test_utf8_ucs2_cvts (cvt); > } > > int > diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h > b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h > index 99d1a4684..fbdc7a35b 100644 > --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h > +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode.h > @@ -15,18 +15,11 @@ > // with this library; see the file COPYING3. If not see > // . > > +#include > #include > #include > -#include > #include > > -template > -std::unique_ptr > -to_unique_ptr (T *ptr) > -{ > - return std::unique_ptr (ptr); > -} > - > struct test_offsets_ok > { > size_t in_size, out_size; > diff --git > a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc > b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc > index 169504939..f7a0a4fd8 100644 > --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc > +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc > @@ -27,8 +27,8 @@ void > test_utf8_utf32_codecvts () > { > #if __SIZEOF_WCHAR_T__ == 4 > - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); > - test_utf8_utf32_codecvts (*cvt_ptr); > + auto cvt = codecvt_utf8 (); > + test_utf8_utf32_codecvts (cvt); > #endif > } > > @@ -36,8 +36,8 @@ void > test_utf8_utf16_codecvts () > { > #if __SIZEOF_WCHAR_T__ >= 2 > - auto cvt_ptr = to_unique_ptr (new codecvt_utf8_utf16 ()); > - test_utf8_utf16_cvts (*cvt_ptr); > + auto cvt = codecvt_utf8_utf16 (); > + test_utf8_utf16_cvts (cvt); > #endif > } > > @@ -45,8 +45,8 @@ void > test_utf8_ucs2_codecvts () > { > #if __SIZEOF_WCHAR_T__ == 2 > - auto cvt_ptr = to_unique_ptr (new codecvt_utf8 ()); > - test_utf8_ucs2_cvts (*cvt_ptr); > + auto cvt = codecvt_utf8 (); > + test_utf8_ucs2_cvts (cvt); > #endif > } > > -- > 2.34.1 > > > --000000000000b0842605f27c7799--