From patchwork Tue Nov 21 12:04:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lancelot SIX X-Patchwork-Id: 80468 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F3763858C29 for ; Tue, 21 Nov 2023 12:08:31 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2076.outbound.protection.outlook.com [40.107.92.76]) by sourceware.org (Postfix) with ESMTPS id 2D1DA3858037 for ; Tue, 21 Nov 2023 12:06:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D1DA3858037 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D1DA3858037 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.92.76 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568369; cv=pass; b=qNZF0kxJRyH19hIe3NAoyg8xC0jMU5T59EsUuCLJzpTtV18Z9h070aJ3kSp/stUooG7VOxd4t9okQPFT1ghpBPNfzYpSgPMvELhw7y9djC9TZIe09iaIFKQIbqvld1ltbBqTOHA9CAIfDrxV6suxt6gIDKube9W298oQxzXNhUQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700568369; c=relaxed/simple; bh=1l0oPZkq4ahe7zwVi/6QVIRyDr0osE9F3W9Sal6xLQI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nq+UFhFjTCQ80/Nr7jllowOePPNc/GJFlY0pj3LjcSAQnIMW3kk0aXjSDUpUsMdP7Zc/LeSKn8qXFy/k/D8czVswqD0b09mk5ES37CQmyrvgyoLIhRuBJbkEH3KZ+o11L4vQwmhDEVXo/OGK8yjPr8k1TSZ1lLmCrexdszT8txA= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D2KhWYQ23pjMGp+Z+VMUvSqHUpydNLJ7mepzqWuOJb9gVHNS7I/dpr/EPwbGNq3cm+UyPjP1sWvIPu44yItLiv8RTWjl7TXpPy2Kzv4BK75UDUZ+Lgz7nd6vOyVbRL/IM3jYfIpfQQBzYd/BVeBzirQUJDzMSFeEwTVVg/1F6/ulYmfZjmqS6Xw3TjuX0tD67BKWFSBdTERLcxpdYUfUUUOE4VdLxUJDk3eMbPU3hsrsbVvoSsScj/oMtwD+5Tt5IZseE4us4N5k9TcHl7PH/mh16RE3rU7LNY655uL6C3dQOBTi3iBqNrNAMeoCSTa5+sRo8kA3+W77pwhbx6bqJQ== 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=bB0sgpescX3Ea8zfgwjilJc/9RfiRNcsyxvFv4dyRv8=; b=PevYjbWk7E7kZK1mMh3nQn9GUzb4XpntXUeHalqFs418QUEU9DvxT/MNEFDXJ9P7h3za0bPiA+AI+6kb2enytHDHGZVXM0QpdPBRT52W6i5nkvtRQWNvo67/DJWSU5E4MjPrnzmlEXW9g7joofBltFWfr/D1b5cwgjKvZpxhlmWTiUk748jfiuj8BxInmw7bQbM8WteR3yQyEKqup+alt+kRosQdom+GibBYrE32HyAxfi8lle1Fv/gb1helCq/Oxpw8GyNXUCmZF0EKUkuZfbFJwjPZlwaHRu3GIeuQi9/dIsLF3mFLBpjA0ZtwYNxD0d0oid5uvyM2gG4X3563qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bB0sgpescX3Ea8zfgwjilJc/9RfiRNcsyxvFv4dyRv8=; b=gzF14b8nczPGKUS8i9wcuDYSpQ4dPgt3CvpF2KzANIsx6QrgFfkeWDkrpnzDkalejqlOtbV5SiK0OJKILsEOJ8jtfi1Z08+jX0aiVxNIyA8LWoMgyAkDvAIJWmKUO+VTJJFEsHKUQvqMDAz4dX/JziVxaEvzJe6kWeNuNkhkhvM= Received: from BL1PR13CA0349.namprd13.prod.outlook.com (2603:10b6:208:2c6::24) by CY5PR12MB6036.namprd12.prod.outlook.com (2603:10b6:930:2c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 12:05:54 +0000 Received: from MN1PEPF0000F0E1.namprd04.prod.outlook.com (2603:10b6:208:2c6:cafe::92) by BL1PR13CA0349.outlook.office365.com (2603:10b6:208:2c6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MN1PEPF0000F0E1.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Tue, 21 Nov 2023 12:05:54 +0000 Received: from hpe6u-23.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 21 Nov 2023 06:05:52 -0600 From: Lancelot Six To: CC: , , Lancelot Six Subject: [COMMITTED PATCH v2 6/9] gdbsupport: Remove gdb::string_view Date: Tue, 21 Nov 2023 12:04:57 +0000 Message-ID: <20231121120500.1394523-7-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> References: <20231028204821.fp5hh7bahrmrnpjl@hpe6u-23> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E1:EE_|CY5PR12MB6036:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a597e05-5662-46eb-841e-08dbea8a3680 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kkg8KMyCIyAfG5dYgUVxoyBNQV3xY8vnZMDEYoTkmn7m93NpHDL19Fc0C8nb2YSrjMRv9WO2rwSWOgl+tBgubqebhKUudOHcultNh1oj/rVY48WqY+ZOTNEbrWCg+tsHmqgQztSsE0aFI1/Y+LEHr/qnGG3ElKvkj2xQQ5weiwD9p3CBkNKOaf+R8Q3/M9NySP++nFFWj1M0XIcRjDSghRIDK24CxEqXI/ntQlcunlzwT/h70CYquAKLt7fht/ftBpwvLpjnLUPDGHr2laykURsyvkl0bYCGbon94wL2UirCoqR2f+127ooRGStEz3zzGjJQaSZYyHD5KEnI4asCTzCN6GI/W9392+/wPFxgZPB4ngfVO+ynzc/VondPXBaUvB6QhtmW68nKw0XyLcs+EcPETj5hPFOSWUIusxZWnxJh9+WTEEkAhwt3qfk2PiVhuuxQAOyzZx8KI+RnNZvenit+2bD1HmYPO+6e6unIryBgAEKhuCsT8gAV9hL2qht7dZJpQroRWPbaS75oGx3CTg6pLzwWyC1yVD/+CO1JI+kxqBriqWhWamaqFyxPF4XK6wXZ61veL0w59q2YgGpbqWSdfXm7dQo0X3YALE86KKAeVxKe8XtNG+7iOFQPt8pdhF72fykGSGO7o+r36PmvDE1bbr2O8ELY4lfP2JAZaAWK2IBh0HgjX5kiVlx5FkdUyDEMfeVhGy1GN7jJY3NDcr340NVZ5a5hbxWT08bYzHNPdOAMUQjY+3lISB1rT7yhELHzeRq9PKR6kSnNmFA5sPlc13Q6XoOL7+SjXgWTNxM767r/GGsEpXr33p1aFI1/giKEJeHVSFv1GZXAQDPSF/WaSj0gjUBZ8smpDTivYKE= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(376002)(396003)(346002)(230273577357003)(230173577357003)(230922051799003)(64100799003)(186009)(1800799012)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(54906003)(70586007)(70206006)(36756003)(82740400003)(356005)(81166007)(86362001)(36860700001)(336012)(26005)(83380400001)(16526019)(1076003)(7696005)(2616005)(966005)(2906002)(426003)(6916009)(316002)(478600001)(41300700001)(8676002)(4326008)(5660300002)(47076005)(44832011)(8936002)(30864003)(2004002)(36900700001)(579004)(559001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 12:05:54.3366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a597e05-5662-46eb-841e-08dbea8a3680 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6036 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Now that all places using gdb::string_view have been updated to use std::string_view, this patch drops the gdb::string_view implementation and the tests which came with it. As this drops the unittests/string_view-selftests.c, this also implicitly solves PR build/23676, as pointed-out by Tom Tromey. Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0 Approved-By: Tom Tromey Approved-By: Pedro Alves Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23676 --- gdb/Makefile.in | 1 - gdb/unittests/basic_string_view/capacity/1.cc | 172 ------ .../basic_string_view/capacity/empty_neg.cc | 28 - .../basic_string_view/cons/char/1.cc | 67 --- .../basic_string_view/cons/char/2.cc | 46 -- .../basic_string_view/cons/char/3.cc | 39 -- .../basic_string_view/cons/wchar_t/1.cc | 68 --- .../basic_string_view/cons/wchar_t/2.cc | 45 -- .../basic_string_view/cons/wchar_t/3.cc | 38 -- .../element_access/char/1.cc | 70 --- .../element_access/char/2.cc | 30 - .../element_access/char/empty.cc | 39 -- .../element_access/char/front_back.cc | 43 -- .../element_access/wchar_t/1.cc | 71 --- .../element_access/wchar_t/2.cc | 32 - .../element_access/wchar_t/empty.cc | 38 -- .../element_access/wchar_t/front_back.cc | 42 -- gdb/unittests/basic_string_view/include.cc | 25 - .../basic_string_view/inserters/char/1.cc | 65 -- .../basic_string_view/inserters/char/2.cc | 91 --- .../basic_string_view/inserters/char/3.cc | 54 -- .../inserters/pod/10081-out.cc | 75 --- .../basic_string_view/inserters/wchar_t/1.cc | 70 --- .../basic_string_view/inserters/wchar_t/2.cc | 91 --- .../basic_string_view/inserters/wchar_t/3.cc | 53 -- .../basic_string_view/literals/types.cc | 45 -- .../basic_string_view/literals/values.cc | 72 --- .../modifiers/remove_prefix/char/1.cc | 66 -- .../modifiers/remove_prefix/wchar_t/1.cc | 61 -- .../modifiers/remove_suffix/char/1.cc | 66 -- .../modifiers/remove_suffix/wchar_t/1.cc | 61 -- .../modifiers/swap/char/1.cc | 36 -- .../modifiers/swap/wchar_t/1.cc | 35 -- .../operations/compare/char/1.cc | 132 ---- .../operations/compare/char/13650.cc | 50 -- .../operations/compare/char/2.cc | 30 - .../operations/compare/char/70483.cc | 89 --- .../operations/compare/wchar_t/1.cc | 133 ---- .../operations/compare/wchar_t/13650.cc | 49 -- .../operations/compare/wchar_t/2.cc | 30 - .../operations/copy/char/1.cc | 46 -- .../operations/copy/wchar_t/1.cc | 46 -- .../operations/data/char/1.cc | 44 -- .../operations/data/wchar_t/1.cc | 43 -- .../operations/find/char/1.cc | 168 ------ .../operations/find/char/2.cc | 166 ----- .../operations/find/char/3.cc | 166 ----- .../operations/find/char/4.cc | 45 -- .../operations/find/wchar_t/1.cc | 163 ----- .../operations/find/wchar_t/2.cc | 161 ----- .../operations/find/wchar_t/3.cc | 161 ----- .../operations/find/wchar_t/4.cc | 44 -- .../operations/rfind/char/1.cc | 95 --- .../operations/rfind/char/2.cc | 53 -- .../operations/rfind/char/3.cc | 68 --- .../operations/rfind/wchar_t/1.cc | 94 --- .../operations/rfind/wchar_t/2.cc | 52 -- .../operations/rfind/wchar_t/3.cc | 66 -- .../operations/string_conversion/1.cc | 51 -- .../operations/substr/char/1.cc | 79 --- .../operations/substr/wchar_t/1.cc | 79 --- .../basic_string_view/operators/char/2.cc | 373 ------------ .../basic_string_view/operators/wchar_t/2.cc | 367 ------------ .../basic_string_view/range_access/char/1.cc | 47 -- .../range_access/wchar_t/1.cc | 47 -- .../requirements/explicit_instantiation/1.cc | 26 - .../explicit_instantiation/char/1.cc | 23 - .../explicit_instantiation/char16_t/1.cc | 24 - .../explicit_instantiation/char32_t/1.cc | 24 - .../explicit_instantiation/wchar_t/1.cc | 23 - .../requirements/typedefs.cc | 47 -- gdb/unittests/basic_string_view/typedefs.cc | 36 -- gdb/unittests/basic_string_view/types/1.cc | 43 -- gdb/unittests/string_view-selftests.c | 193 ------ gdbsupport/gdb_string_view.h | 566 ------------------ gdbsupport/gdb_string_view.tcc | 219 ------- 76 files changed, 6296 deletions(-) delete mode 100644 gdb/unittests/basic_string_view/capacity/1.cc delete mode 100644 gdb/unittests/basic_string_view/capacity/empty_neg.cc delete mode 100644 gdb/unittests/basic_string_view/cons/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/cons/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/cons/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/empty.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/char/front_back.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc delete mode 100644 gdb/unittests/basic_string_view/include.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/pod/10081-out.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/literals/types.cc delete mode 100644 gdb/unittests/basic_string_view/literals/values.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/13650.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/70483.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/copy/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/data/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/4.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc delete mode 100644 gdb/unittests/basic_string_view/operations/string_conversion/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/substr/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/operators/char/2.cc delete mode 100644 gdb/unittests/basic_string_view/operators/wchar_t/2.cc delete mode 100644 gdb/unittests/basic_string_view/range_access/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/range_access/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc delete mode 100644 gdb/unittests/basic_string_view/requirements/typedefs.cc delete mode 100644 gdb/unittests/basic_string_view/typedefs.cc delete mode 100644 gdb/unittests/basic_string_view/types/1.cc delete mode 100644 gdb/unittests/string_view-selftests.c delete mode 100644 gdbsupport/gdb_string_view.h delete mode 100644 gdbsupport/gdb_string_view.tcc diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 714564f27b4..a50628e8ed0 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -482,7 +482,6 @@ SELFTESTS_SRCS = \ unittests/scoped_mmap-selftests.c \ unittests/scoped_restore-selftests.c \ unittests/search-memory-selftests.c \ - unittests/string_view-selftests.c \ unittests/style-selftests.c \ unittests/tracepoint-selftests.c \ unittests/tui-selftests.c \ diff --git a/gdb/unittests/basic_string_view/capacity/1.cc b/gdb/unittests/basic_string_view/capacity/1.cc deleted file mode 100644 index 12470a98279..00000000000 --- a/gdb/unittests/basic_string_view/capacity/1.cc +++ /dev/null @@ -1,172 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// string_view size, length - -namespace capacity_1 { - -template - struct A { }; - -template - bool - operator==(const A&, const A&) { return true; } - -template - bool - operator<(const A&, const A&) { return true; } - -struct B { }; - -} // namespace capacity_1 -} // namespace string_view -} // namespace selftests - -// char_traits specialization -namespace std -{ - template<> - struct char_traits > - { - typedef selftests::string_view::capacity_1::A< - selftests::string_view::capacity_1::B> char_type; - // Unsigned as wint_t in unsigned. - typedef unsigned long int_type; - typedef streampos pos_type; - typedef streamoff off_type; - typedef mbstate_t state_type; - - static void - assign(char_type& __c1, const char_type& __c2) - { __c1 = __c2; } - - static bool - eq(const char_type& __c1, const char_type& __c2) - { return __c1 == __c2; } - - static bool - lt(const char_type& __c1, const char_type& __c2) - { return __c1 < __c2; } - - static int - compare(const char_type* __s1, const char_type* __s2, size_t __n) - { - for (size_t __i = 0; __i < __n; ++__i) - if (!eq(__s1[__i], __s2[__i])) - return lt(__s1[__i], __s2[__i]) ? -1 : 1; - return 0; - } - - static size_t - length(const char_type* __s) - { - const char_type* __p = __s; - while (__p) - ++__p; - return (__p - __s); - } - - static const char_type* - find(const char_type* __s, size_t __n, const char_type& __a) - { - for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) - if (*__p == __a) return __p; - return 0; - } - - static char_type* - move(char_type* __s1, const char_type* __s2, size_t __n) - { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } - - static char_type* - copy(char_type* __s1, const char_type* __s2, size_t __n) - { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } - - static char_type* - assign(char_type* __s, size_t __n, char_type __a) - { - for (char_type* __p = __s; __p < __s + __n; ++__p) - assign(*__p, __a); - return __s; - } - - static char_type - to_char_type(const int_type&) - { return char_type(); } - - static int_type - to_int_type(const char_type&) { return int_type(); } - - static bool - eq_int_type(const int_type& __c1, const int_type& __c2) - { return __c1 == __c2; } - - static int_type - eof() { return static_cast(-1); } - - static int_type - not_eof(const int_type& __c) - { return eq_int_type(__c, eof()) ? int_type(0) : __c; } - }; -} // namespace std - -namespace selftests { -namespace string_view { -namespace capacity_1 { - -static void -test01 () -{ - gdb::basic_string_view> str02; - typedef gdb::basic_string_view< A >::size_type size_type_o; - size_type_o sz03; - size_type_o sz04; - - // non-POD types: size, length, max_size, empty() - bool b01 = str02.empty(); - VERIFY( b01 == true ); - sz03 = str02.size(); - sz04 = str02.length(); - VERIFY( sz03 == sz04 ); - str02.data(); - sz03 = str02.size(); - sz04 = str02.length(); - VERIFY( sz03 == sz04 ); - - sz03 = str02.max_size(); - VERIFY( sz03 >= sz04 ); - - sz03 = str02.size(); - str02 = {}; - b01 = str02.empty(); - VERIFY( b01 == true ); - sz04 = str02.size(); - VERIFY( sz03 >= sz04 ); -} - -static int -main() -{ - test01(); - - return 0; -} - -} // namespace capacity_1 diff --git a/gdb/unittests/basic_string_view/capacity/empty_neg.cc b/gdb/unittests/basic_string_view/capacity/empty_neg.cc deleted file mode 100644 index 4cb1beac5a6..00000000000 --- a/gdb/unittests/basic_string_view/capacity/empty_neg.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -void -test01() -{ - std::string_view s; - s.empty(); // { dg-warning "ignoring return value" } -} diff --git a/gdb/unittests/basic_string_view/cons/char/1.cc b/gdb/unittests/basic_string_view/cons/char/1.cc deleted file mode 100644 index b27f999e429..00000000000 --- a/gdb/unittests/basic_string_view/cons/char/1.cc +++ /dev/null @@ -1,67 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -namespace cons_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - - // basic_string_view() - const gdb::string_view str00{}; - VERIFY( str00.length() == 0 ); - VERIFY( str00.data() == nullptr ); - - // basic_string_view(const char*) - const char str_lit01[] = "rodeo beach, marin"; - const gdb::string_view str01{str_lit01}; - VERIFY( str01.length() == 18 ); - VERIFY( str01.data() == str_lit01 ); - const gdb::string_view str02{"baker beach, san francisco"}; - VERIFY( str02.length() == 26 ); - - // basic_string_view(const string_view&) - gdb::string_view str04{str01}; - VERIFY( str04.length() == str01.length() ); - VERIFY( str04.data() == str01.data() ); - - // basic_string_view(const char* s) - csize_type len_lit01 = strlen(str_lit01); - gdb::string_view str05{str_lit01, len_lit01}; - VERIFY( str05.length() == len_lit01 ); - VERIFY( str05.data() == str_lit01 ); - - // basic_string_view(basic_string& s) - std::string istr07(10, 'z'); - gdb::string_view str07{istr07}; - VERIFY( str07.length() == 10 ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace cons_1 diff --git a/gdb/unittests/basic_string_view/cons/char/2.cc b/gdb/unittests/basic_string_view/cons/char/2.cc deleted file mode 100644 index 22a7916c9e3..00000000000 --- a/gdb/unittests/basic_string_view/cons/char/2.cc +++ /dev/null @@ -1,46 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -namespace cons_2 { - -static void -test03 () -{ - const char* with_nulls = "This contains \0 a zero byte."; - - // These are tests to see how basic_string_view handles data with NUL - // bytes. Obviously basic_string_view(char*) will halt at the first one, but - // nothing else should. - gdb::string_view s1(with_nulls, 28); - VERIFY( s1.size() == 28 ); - gdb::string_view s2(s1); - VERIFY( s2.size() == 28 ); -} - -static int -main () -{ - test03(); - - return 0; -} - -} // namespace cons_2 diff --git a/gdb/unittests/basic_string_view/cons/char/3.cc b/gdb/unittests/basic_string_view/cons/char/3.cc deleted file mode 100644 index ab98b0b70a4..00000000000 --- a/gdb/unittests/basic_string_view/cons/char/3.cc +++ /dev/null @@ -1,39 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -namespace cons_3 { - -static void -test05 () -{ - char const * s = 0; - gdb::string_view zero_length_built_with_NULL(s, 0); -} - -static int -main () -{ - test05(); - - return 0; -} - -} // namespace cons_3 diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc b/gdb/unittests/basic_string_view/cons/wchar_t/1.cc deleted file mode 100644 index 8a1599c5b81..00000000000 --- a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc +++ /dev/null @@ -1,68 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -#include -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - - // basic_string_view() - const std::wstring_view str00{}; - VERIFY( str00.length() == 0 ); - VERIFY( str00.data() == nullptr ); - - // basic_string_view(const char*) - const wchar_t str_lit01[] = L"rodeo beach, marin"; - const std::wstring_view str01{str_lit01}; - VERIFY( str01.length() == 18 ); - VERIFY( str01.data() == str_lit01 ); - const std::wstring_view str02{L"baker beach, san francisco"}; - VERIFY( str02.length() == 26 ); - - // basic_string_view(const string_view&) - std::wstring_view str04{str01}; - VERIFY( str04.length() == str01.length() ); - VERIFY( str04.data() == str01.data() ); - - // basic_string_view(const char* s) - csize_type len_lit01 = wcslen(str_lit01); - std::wstring_view str05{str_lit01, len_lit01}; - VERIFY( str05.length() == len_lit01 ); - VERIFY( str05.data() == str_lit01 ); - - // basic_string_view(basic_string& s) - std::wstring istr07(10, L'z'); - std::wstring_view str07{istr07}; - VERIFY( str07.length() == 10 ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc b/gdb/unittests/basic_string_view/cons/wchar_t/2.cc deleted file mode 100644 index 54a7fe509bb..00000000000 --- a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc +++ /dev/null @@ -1,45 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -#include -#include - -void -test03() -{ - const wchar_t* with_nulls = L"This contains \0 a zero byte."; - - // These are tests to see how basic_string_view handles data with NUL - // bytes. Obviously basic_string_view(char*) will halt at the first one, but - // nothing else should. - std::wstring_view s1 (with_nulls, 28); - VERIFY( s1.size() == 28 ); - std::wstring_view s2 (s1); - VERIFY( s2.size() == 28 ); -} - -int -main() -{ - test03(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc b/gdb/unittests/basic_string_view/cons/wchar_t/3.cc deleted file mode 100644 index 540683f5421..00000000000 --- a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc +++ /dev/null @@ -1,38 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view constructors. - -#include -#include - -void -test05() -{ - wchar_t const * s = 0; - std::wstring_view zero_length_built_with_NULL(s, 0); -} - -int -main() -{ - test05(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/element_access/char/1.cc b/gdb/unittests/basic_string_view/element_access/char/1.cc deleted file mode 100644 index 788d174d852..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/1.cc +++ /dev/null @@ -1,70 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string element access - -namespace element_access_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type csz01; - - const gdb::string_view str01("tamarindo, costa rica"); - gdb::string_view str02("41st street beach, capitola, california"); - gdb::string_view str03; - - // const_reference operator[] (size_type pos) const; - csz01 = str01.size(); - cref cref1 = str01[csz01 - 1]; - VERIFY( cref1 == 'a' ); - // Undefined behavior at size(). - //cref cref2 = str01[csz01]; - //VERIFY( cref2 == char() ); - - // const_reference at(size_type pos) const; - csz01 = str01.size(); - cref cref3 = str01.at(csz01 - 1); - VERIFY( cref3 == 'a' ); - try - { - str01.at(csz01); - VERIFY( false ); // Should not get here, as exception thrown. - } - catch (gdb_exception& fail) - { - VERIFY( true ); - } - catch (...) - { - VERIFY( false ); - } -} - -static int -main () -{ - test01(); - return 0; -} - -} // namespace element_access_1 diff --git a/gdb/unittests/basic_string_view/element_access/char/2.cc b/gdb/unittests/basic_string_view/element_access/char/2.cc deleted file mode 100644 index 938916e2924..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/2.cc +++ /dev/null @@ -1,30 +0,0 @@ -// { dg-do run { xfail *-*-* } } -// { dg-options "-std=gnu++17 -O0" } -// { dg-require-debug-mode "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include - -int -main() -{ - typedef std::string_view string_view_type; - string_view_type s; - s[0]; // abort -} diff --git a/gdb/unittests/basic_string_view/element_access/char/empty.cc b/gdb/unittests/basic_string_view/element_access/char/empty.cc deleted file mode 100644 index 030c96aa073..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/empty.cc +++ /dev/null @@ -1,39 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . -// - -namespace element_access_empty { - -static int -main () -{ - { - gdb::string_view empty; - VERIFY( empty.empty() ); - } - - { - const gdb::string_view empty; - VERIFY( empty.empty() ); - } - - return 0; -} - -} // namespace element_access_empty diff --git a/gdb/unittests/basic_string_view/element_access/char/front_back.cc b/gdb/unittests/basic_string_view/element_access/char/front_back.cc deleted file mode 100644 index 7e767fc7910..00000000000 --- a/gdb/unittests/basic_string_view/element_access/char/front_back.cc +++ /dev/null @@ -1,43 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-require-string-conversions "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace element_access_front_back { - -static void -test01 () -{ - gdb::string_view str("ramifications"); - const gdb::string_view cstr("melodien"); - - VERIFY( str.front() == 'r' ); - VERIFY( str.back() == 's' ); - VERIFY( cstr.front() == 'm' ); - VERIFY( cstr.back() == 'n' ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace element_access_front_back diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc deleted file mode 100644 index 679772b4c57..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc +++ /dev/null @@ -1,71 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view element access - -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type csz01, csz02; - - const std::wstring_view str01(L"tamarindo, costa rica"); - std::wstring_view str02(L"41st street beach, capitola, california"); - std::wstring_view str03; - - // const_reference operator[] (size_type pos) const; - csz01 = str01.size(); - cref cref1 = str01[csz01 - 1]; - VERIFY( cref1 == L'a' ); - // Undefined behavior at size(). - //cref cref2 = str01[csz01]; - //VERIFY( cref2 == wchar_t() ); - - // const_reference at(size_type pos) const; - csz01 = str01.size(); - cref cref3 = str01.at(csz01 - 1); - VERIFY( cref3 == L'a' ); - try - { - str01.at(csz01); - VERIFY( false ); // Should not get here, as exception thrown. - } - catch (std::out_of_range& fail) - { - VERIFY( true ); - } - catch (...) - { - VERIFY( false ); - } -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc deleted file mode 100644 index cdbc6a5e5a8..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc +++ /dev/null @@ -1,32 +0,0 @@ -// { dg-do run { xfail *-*-* } } -// { dg-options "-std=gnu++17 -O0" } -// { dg-require-debug-mode "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include - -// libstdc++/21674 -// NB: Should work without any inlining or optimizations (ie. -O0). -int -main() -{ - typedef std::wstring_view string_view_type; - string_view_type s; - s[0]; // abort -} diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc deleted file mode 100644 index f31d34aa42b..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc +++ /dev/null @@ -1,38 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . -// - -#include -#include - -int -main() -{ - { - std::wstring_view empty; - VERIFY( empty.empty() ); - } - - { - const std::wstring_view empty; - VERIFY( empty.empty() ); - } - - return 0; -} diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc deleted file mode 100644 index c17a08a45c7..00000000000 --- a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc +++ /dev/null @@ -1,42 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-require-string-conversions "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - std::wstring_view str(L"ramifications"); - const std::wstring_view cstr(L"melodien"); - - VERIFY( str.front() == L'r' ); - VERIFY( str.back() == L's' ); - VERIFY( cstr.front() == L'm' ); - VERIFY( cstr.back() == L'n' ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/include.cc b/gdb/unittests/basic_string_view/include.cc deleted file mode 100644 index ef01b7c478c..00000000000 --- a/gdb/unittests/basic_string_view/include.cc +++ /dev/null @@ -1,25 +0,0 @@ -// -*- C++ -*- - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// NB: This issue affected only debug-mode. - -// { dg-options "-std=gnu++17 -fno-rtti" } -// { dg-do compile } - -#include diff --git a/gdb/unittests/basic_string_view/inserters/char/1.cc b/gdb/unittests/basic_string_view/inserters/char/1.cc deleted file mode 100644 index e0a33bf13bd..00000000000 --- a/gdb/unittests/basic_string_view/inserters/char/1.cc +++ /dev/null @@ -1,65 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include -#include -#include - -void -test01() -{ - typedef std::string_view::size_type csize_type; - typedef std::string_view::const_reference cref; - typedef std::string_view::reference ref; - - const std::string_view str01("sailing grand traverse bay\n" - "\t\t\t from Elk Rapids to the point reminds me of miles"); - - // ostream& operator<<(ostream&, const basic_string_view&) - std::ostringstream ostrs01; - try - { - ostrs01 << str01; - VERIFY( ostrs01.str() == str01 ); - } - catch(std::exception& fail) - { - VERIFY( false ); - } - - std::string_view hello_world; - std::cout << hello_world; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/char/2.cc b/gdb/unittests/basic_string_view/inserters/char/2.cc deleted file mode 100644 index 840f52185df..00000000000 --- a/gdb/unittests/basic_string_view/inserters/char/2.cc +++ /dev/null @@ -1,91 +0,0 @@ - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -// { dg-options "-std=gnu++17" } -// { dg-require-fileio "" } - -namespace inserters_2 { - -// testing basic_filebuf::xsputn via stress testing with large string_views -// based on a bug report libstdc++ 9 -// mode == out -static void -test05 (std::size_t size) -{ - bool test ATTRIBUTE_UNUSED = true; - - const char filename[] = "inserters_extractors-2.txt"; - const char fillc = 'f'; - std::ofstream ofs(filename); - std::string str(size, fillc); - gdb::string_view strv{str}; - - // sanity checks - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - // stress test - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - ofs.close(); - - // sanity check on the written file - std::ifstream ifs(filename); - std::size_t count = 0; - char c; - while (count <= (2 * size) + 4) - { - ifs >> c; - if (ifs.good() && c == fillc) - { - ++count; - c = '0'; - } - else - break; - } - - VERIFY( count == 2 * size ); -} - -static int -main () -{ - test05(1); - test05(1000); - test05(10000); - - return 0; -} - -} // namespace inserters_2 diff --git a/gdb/unittests/basic_string_view/inserters/char/3.cc b/gdb/unittests/basic_string_view/inserters/char/3.cc deleted file mode 100644 index 43e3ae05ba7..00000000000 --- a/gdb/unittests/basic_string_view/inserters/char/3.cc +++ /dev/null @@ -1,54 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include - -// libstdc++/2830 -void -test09() -{ - std::string_view foo{"peace\0\0\0& love"}; - - std::ostringstream oss1; - oss1 << foo; - VERIFY( oss1.str() == foo ); - - std::ostringstream oss2; - oss2.width(20); - oss2 << foo; - VERIFY( oss2.str() != foo ); - VERIFY( oss2.str().size() == 20 ); -} - -int -main() -{ - test09(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc b/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc deleted file mode 100644 index 4b5d81d33cf..00000000000 --- a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc +++ /dev/null @@ -1,75 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// class basic_istream::sentry - -#include -#include -#include -#include -#include -#include -#include - -void -test01() -{ - using namespace std; - - using __gnu_test::pod_ushort; - typedef basic_string_view string_type; - typedef basic_stringbuf stringbuf_type; - typedef basic_ostream ostream_type; - - string_type str; - stringbuf_type strbuf01; - ostream_type stream(&strbuf01); - - try - { - stream << str; - } - catch (std::bad_cast& obj) - { - // Ok, throws bad_cast because locale has no ctype facet. - } - catch (...) - { - VERIFY( false ); - } - - const std::locale loc(std::locale::classic(), new std::ctype); - stream.imbue(loc); - try - { - stream << str; - } - catch (...) - { - VERIFY( false ); - } -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc deleted file mode 100644 index 69754254e4f..00000000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc +++ /dev/null @@ -1,70 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - - const std::wstring_view str01(L"sailing grand traverse bay\n" - L"\t\t\t from Elk Rapids to the point reminds me of miles"); - const std::wstring_view str02(L"sailing"); - const std::wstring_view str03(L"grand"); - const std::wstring_view str04(L"traverse"); - const std::wstring_view str05; - std::wstring_view str10; - - // ostream& operator<<(ostream&, const basic_string_view&) - std::wostringstream ostrs01; - try - { - ostrs01 << str01; - VERIFY( ostrs01.str() == str01 ); - } - catch(std::exception& fail) - { - VERIFY( false ); - } - - std::wstring_view hello_world; - std::wcout << hello_world; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc deleted file mode 100644 index 5cc3e93e5b7..00000000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc +++ /dev/null @@ -1,91 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include -#include - -// testing basic_filebuf::xsputn via stress testing with large string_views -// based on a bug report libstdc++ 9 -// mode == out -void -test05(std::size_t size) -{ - bool test = true; - - const char filename[] = "inserters_extractors-2.txt"; - const wchar_t fillc = L'f'; - std::wofstream ofs(filename); - std::wstring str(size, fillc); - std::wstring_view strv(str); - - // sanity checks - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - // stress test - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - ofs.close(); - - // sanity check on the written file - std::wifstream ifs(filename); - std::size_t count = 0; - wchar_t c; - while (count <= (2 * size) + 4) - { - ifs >> c; - if (ifs.good() && c == fillc) - { - ++count; - c = '0'; - } - else - break; - } - - VERIFY( count == 2 * size ); -} - -int -main() -{ - test05(1); - test05(1000); - test05(10000); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc deleted file mode 100644 index 5eabf46dd44..00000000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc +++ /dev/null @@ -1,53 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include -#include -#include -#include - -void -test09() -{ - std::wstring_view foo{L"peace\0\0\0& love"}; - - std::wostringstream oss1; - oss1 << foo; - VERIFY( oss1.str() == foo ); - - std::wostringstream oss2; - oss2.width(20); - oss2 << foo; - VERIFY( oss2.str() != foo ); - VERIFY( oss2.str().size() == 20 ); -} - -int -main() -{ - test09(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/literals/types.cc b/gdb/unittests/basic_string_view/literals/types.cc deleted file mode 100644 index de0aa1e7569..00000000000 --- a/gdb/unittests/basic_string_view/literals/types.cc +++ /dev/null @@ -1,45 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using namespace std::literals::string_view_literals; - - static_assert(std::is_same::value, - "\"Hello\"s is std::string_view"); - - static_assert(std::is_same::value, - "u8\"Hello\"s is std::string_view"); - -#ifdef _GLIBCXX_USE_WCHAR_T - static_assert(std::is_same::value, - "L\"Hello\"s is std::wstring_view"); -#endif - - static_assert(std::is_same::value, - "u\"Hello\"s is std::u16string_view"); - - static_assert(std::is_same::value, - "U\"Hello\"s is std::u32string_view"); -} diff --git a/gdb/unittests/basic_string_view/literals/values.cc b/gdb/unittests/basic_string_view/literals/values.cc deleted file mode 100644 index ebd69b84455..00000000000 --- a/gdb/unittests/basic_string_view/literals/values.cc +++ /dev/null @@ -1,72 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using namespace std::literals::string_view_literals; - - std::string_view planet = "Mercury"sv; -#ifdef _GLIBCXX_USE_WCHAR_T - std::wstring_view wplanet = L"Venus"sv; -#endif - std::string_view u8planet = u8"Mars"sv; - std::u16string_view u16planet = u"Jupiter"sv; - std::u32string_view u32planet = U"Saturn"sv; - - VERIFY( planet == std::string_view("Mercury") ); -#ifdef _GLIBCXX_USE_WCHAR_T - VERIFY( wplanet == std::wstring_view(L"Venus") ); -#endif - VERIFY( u8planet == std::string_view(u8"Mars") ); - VERIFY( u16planet == std::u16string_view(u"Jupiter") ); - VERIFY( u32planet == std::u32string_view(U"Saturn") ); -} - -void -test02() -{ - using namespace std::literals::string_view_literals; - - std::string_view planet_cratered = "Mercury\0cratered"sv; -#ifdef _GLIBCXX_USE_WCHAR_T - std::wstring_view wplanet_cratered = L"Venus\0cratered"sv; -#endif - std::string_view u8planet_cratered = u8"Mars\0cratered"sv; - std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv; - std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv; - - VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) ); -#ifdef _GLIBCXX_USE_WCHAR_T - VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) ); -#endif - VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) ); - VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) ); - VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) ); -} - -int -main() -{ - test01(); - test02(); -} diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc deleted file mode 100644 index 4ebf4c04ad2..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc +++ /dev/null @@ -1,66 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace modifiers_remove_prefix { - -static void -test01 () -{ - using gdb::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_prefix(4); - VERIFY( str0.data() == p + 4); - VERIFY( str0.length() == 8 ); - VERIFY( str0 == string_view{"pus mons"} ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test02() -{ - using std::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_prefix(4); - if ( str0.data() != p + 4) - return false; - if ( str0.length() != 8 ) - return false; - if ( str0 != string_view{"pus mons"} ) - return false; - - return true; -} -#endif - -static int -main () -{ - test01(); -#ifndef GDB_STRING_VIEW - static_assert( test02() ); -#endif - - return 0; -} - -} // namespace modifiers_remove_prefix diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc deleted file mode 100644 index 3503dcbab53..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc +++ /dev/null @@ -1,61 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_prefix(4); - VERIFY( str0.data() == p + 4); - VERIFY( str0.length() == 8 ); - VERIFY( str0 == wstring_view{L"pus mons"} ); -} - -constexpr bool -test02() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_prefix(4); - if ( str0.data() != p + 4) - return false; - if ( str0.length() != 8 ) - return false; - if ( str0 != wstring_view{L"pus mons"} ) - return false; - - return true; -} - -int -main() -{ - test01(); - static_assert( test02() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc deleted file mode 100644 index 5e9259eecad..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc +++ /dev/null @@ -1,66 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace modifiers_remove_suffix { - -static void -test01 () -{ - using gdb::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_suffix(2); - VERIFY( str0.data() == p); - VERIFY( str0.length() == 10 ); - VERIFY( str0 == string_view{"olympus mo"} ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test02() -{ - using std::string_view; - - string_view str0{"olympus mons"}; - string_view::pointer p = str0.data(); - str0.remove_suffix(2); - if ( str0.data() != p) - return false; - if ( str0.length() != 10 ) - return false; - if ( str0 != string_view{"olympus mo"} ) - return false; - - return true; -} -#endif - -static int -main () -{ - test01(); -#ifndef GDB_STRING_VIEW - static_assert( test02() ); -#endif - - return 0; -} - -} // namespace modifiers_remove_suffix diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc deleted file mode 100644 index 7f9e051d986..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc +++ /dev/null @@ -1,61 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -void -test01() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_suffix(2); - VERIFY( str0.data() == p); - VERIFY( str0.length() == 10 ); - VERIFY( str0 == wstring_view{L"olympus mo"} ); -} - -constexpr bool -test02() -{ - using std::wstring_view; - - wstring_view str0{L"olympus mons"}; - wstring_view::pointer p = str0.data(); - str0.remove_suffix(2); - if ( str0.data() != p) - return false; - if ( str0.length() != 10 ) - return false; - if ( str0 != wstring_view{L"olympus mo"} ) - return false; - - return true; -} - -int -main() -{ - test01(); - static_assert( test02() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc deleted file mode 100644 index d583566c4bd..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -namespace modifiers_swap { - -static void -test01 () -{ - using gdb::string_view; - - string_view s1{"last"}; - string_view s2{"first"}; - - s1.swap(s2); - VERIFY( s1 == "first" ); - VERIFY( s2 == "last" ); -} - -} // namespace modifiers_swap diff --git a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc deleted file mode 100644 index b986088f1e2..00000000000 --- a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -constexpr bool -test01() -{ - using std::wstring_view; - - wstring_view s1{L"last"}; - wstring_view s2{L"first"}; - - s1.swap(s2); - return s1 == L"first" && s2 == L"last"; -} - -static_assert( test01() ); diff --git a/gdb/unittests/basic_string_view/operations/compare/char/1.cc b/gdb/unittests/basic_string_view/operations/compare/char/1.cc deleted file mode 100644 index d824c8e2277..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/char/1.cc +++ /dev/null @@ -1,132 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::compare -// int compare(const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str, -// size_type pos2, size_type n2) const; -// int compare(const charT* s) const; -// int compare(size_type pos1, size_type n1, -// const charT* s, size_type n2 = npos) const; - -// NB compare should be thought of as a lexographical compare, ie how -// things would be sorted in a dictionary. - -namespace operations_compare_1 { - -enum want_value {lt=0, z=1, gt=2}; - -int -test_value(int result, want_value expected); - -int -test_value(int result, want_value expected) -{ - bool pass = false; - - switch (expected) { - case lt: - if (result < 0) - pass = true; - break; - case z: - if (!result) - pass = true; - break; - case gt: - if (result > 0) - pass = true; - break; - default: - pass = false; //should not get here - } - VERIFY(pass); - return 0; -} - -static int -test01 () -{ - using gdb::string_view; - - string_view str_0("costa rica"); - string_view str_1("costa marbella"); - string_view str_2; - - //sanity check - test_value(strcmp("costa marbella", "costa rica"), lt); - test_value(strcmp("costa rica", "costa rica"), z); - test_value(strcmp(str_1.data(), str_0.data()), lt); - test_value(strcmp(str_0.data(), str_1.data()), gt); - test_value(strncmp(str_1.data(), str_0.data(), 6), z); - test_value(strncmp(str_1.data(), str_0.data(), 14), lt); - test_value(memcmp(str_1.data(), str_0.data(), 6), z); - test_value(memcmp(str_1.data(), str_0.data(), 10), lt); - test_value(memcmp("costa marbella", "costa rica", 10), lt); - - // int compare(const basic_string_view& str) const; - test_value(str_0.compare(str_1), gt); //because r>m - test_value(str_1.compare(str_0), lt); //because m. - -// basic_string_view::compare [lib.string_view::compare] - -namespace operations_compare_13650 { - -// libstdc++/13650 -static void -test01 () -{ - using gdb::string_view; - - const char lit_01[]{ 'w', 'e', '\0', 'r', 'd' }; - const char lit_02[]{ 'w', 'e', 'i', '\0', 'd' }; - - const char lit_ref_a[]{ 'w', 'e', '\0', 'q', 'd' }; - const string_view str_a(lit_ref_a, 5); - VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); - - const char lit_ref_b[]{ 'w', 'e', 'i' }; - const string_view str_b(lit_ref_b, 3); - VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); -} - -static int -main() -{ - test01(); - - return 0; -} - -} // namespace operations_compare_13650 diff --git a/gdb/unittests/basic_string_view/operations/compare/char/2.cc b/gdb/unittests/basic_string_view/operations/compare/char/2.cc deleted file mode 100644 index f0b76afb427..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/char/2.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -constexpr char c1[] = "one"; -constexpr char c2[] = "two"; - -constexpr std::string_view s1{c1}; -constexpr std::string_view s2{c2}; - -constexpr int n1 = s1.compare(s1); -constexpr int n2 = s1.compare(s2); diff --git a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc b/gdb/unittests/basic_string_view/operations/compare/char/70483.cc deleted file mode 100644 index 259f95f5180..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -struct constexpr_char_traits : std::char_traits -{ - static constexpr size_t - length(const char* val) - { - size_t res = 0; - for (; val[res] != '\0'; ++res) - ; - return res; - } - - static constexpr int - compare(const char* lhs, const char* rhs, std::size_t count) - { - for (size_t pos = 0; pos < count; ++pos) - { - if (lhs[pos] != rhs[pos]) - return lhs[pos] - rhs[pos]; - } - return 0; - } -}; - -using string_view = std::basic_string_view; - -constexpr -string_view get() -{ - string_view res = "x::"; - string_view start_pattern = "x"; - res = res.substr(res.find(start_pattern) + start_pattern.size()); - res = res.substr(0, res.find_first_of(";]")); - res = res.substr(res.rfind("::")); - return res; -} - -static_assert( get() == get() ); - -using std::u16string_view; - -constexpr -u16string_view get16() -{ - u16string_view res = u"x::"; - u16string_view start_pattern = u"x"; - res = res.substr(res.find(start_pattern) + start_pattern.size()); - res = res.substr(0, res.find_first_of(u";]")); - res = res.substr(res.rfind(u"::")); - return res; -} - -static_assert( get16() == get16() ); - -using std::u32string_view; - -constexpr -u32string_view get32() -{ - u32string_view res = U"x::"; - u32string_view start_pattern = U"x"; - res = res.substr(res.find(start_pattern) + start_pattern.size()); - res = res.substr(0, res.find_first_of(U";]")); - res = res.substr(res.rfind(U"::")); - return res; -} - -static_assert( get32() == get32() ); diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc deleted file mode 100644 index 8a05a4053a1..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc +++ /dev/null @@ -1,133 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::compare -// int compare(const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str) const; -// int compare(size_type pos1, size_type n1, const basic_string_view& str, -// size_type pos2, size_type n2) const; -// int compare(const charT* s) const; -// int compare(size_type pos1, size_type n1, -// const charT* s, size_type n2 = npos) const; - -// NB compare should be thought of as a lexographical compare, ie how -// things would be sorted in a dictionary. - -#include -#include - -enum want_value {lt=0, z=1, gt=2}; - -int -test_value(int result, want_value expected); - -int -test_value(int result, want_value expected) -{ - bool pass = false; - - switch (expected) { - case lt: - if (result < 0) - pass = true; - break; - case z: - if (!result) - pass = true; - break; - case gt: - if (result > 0) - pass = true; - break; - default: - pass = false; //should not get here - } - - VERIFY(pass); - return 0; -} - - -int -test01() -{ - using std::wstring_view; - - wstring_view str_0(L"costa rica"); - wstring_view str_1(L"costa marbella"); - wstring_view str_2; - - //sanity check - test_value(wcscmp(L"costa marbella", L"costa rica"), lt); - test_value(wcscmp(L"costa rica", L"costa rica"), z); - test_value(wcscmp(str_1.data(), str_0.data()), lt); - test_value(wcscmp(str_0.data(), str_1.data()), gt); - test_value(wcsncmp(str_1.data(), str_0.data(), 6), z); - test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt); - test_value(wmemcmp(str_1.data(), str_0.data(), 6), z); - test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt); - test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt); - - // int compare(const basic_string_view& str) const; - test_value(str_0.compare(str_1), gt); //because r>m - test_value(str_1.compare(str_0), lt); //because m. - -// basic_string_view::compare [lib.string_view::compare] - -#include -#include - -// libstdc++/13650 -void -test01() -{ - using std::wstring_view; - - const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' }; - const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' }; - - const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' }; - const wstring_view str_a(lit_ref_a, 5); - VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); - - const wchar_t lit_ref_b[] = { L'w', L'e', L'i' }; - const wstring_view str_b(lit_ref_b, 3); - VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc deleted file mode 100644 index c6b6eb91d42..00000000000 --- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2017-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// { dg-options "-std=gnu++17" } -// { dg-do compile { target c++17 } } - -#include - -constexpr wchar_t c1[] = L"one"; -constexpr wchar_t c2[] = L"two"; - -constexpr std::wstring_view s1{c1}; -constexpr std::wstring_view s2{c2}; - -constexpr int n1 = s1.compare(s1); -constexpr int n2 = s1.compare(s2); diff --git a/gdb/unittests/basic_string_view/operations/copy/char/1.cc b/gdb/unittests/basic_string_view/operations/copy/char/1.cc deleted file mode 100644 index f124f3aab46..00000000000 --- a/gdb/unittests/basic_string_view/operations/copy/char/1.cc +++ /dev/null @@ -1,46 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::copy - -namespace operations_copy_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - - const char str_lit01[] = "123456789A"; - const gdb::string_view str01(str_lit01); - char buffer[4] = { 0 }; - - csize_type len = str01.copy(buffer, sizeof(buffer), 8); - VERIFY( 2 == len ); - VERIFY( '9' == buffer[0] ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_copy_1 diff --git a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc deleted file mode 100644 index 56a48841ca7..00000000000 --- a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc +++ /dev/null @@ -1,46 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::copy - -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - csize_type csz01; - - const wchar_t str_lit01[] = L"123456789A"; - const std::wstring_view str01(str_lit01); - wchar_t buffer[4] = { 0 }; - - csize_type len = str01.copy(buffer, sizeof(buffer), 8); - VERIFY( 2 == len ); - VERIFY( L'9' == buffer[0] ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/data/char/1.cc b/gdb/unittests/basic_string_view/operations/data/char/1.cc deleted file mode 100644 index 0309f5f555d..00000000000 --- a/gdb/unittests/basic_string_view/operations/data/char/1.cc +++ /dev/null @@ -1,44 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// string_view operations - -namespace operations_data_1 { - -static int -test01 () -{ - gdb::string_view empty; - - VERIFY( empty.size() == 0 ); - const gdb::string_view::value_type* p = empty.data(); - VERIFY( p == nullptr ); - - return 0; -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_data_1 diff --git a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc deleted file mode 100644 index 31c58b6a3c2..00000000000 --- a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc +++ /dev/null @@ -1,43 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// string_view operations - -#include -#include - -int -test01() -{ - std::wstring_view empty; - - VERIFY( empty.size() == 0 ); - const std::wstring_view::value_type* p = empty.data(); - VERIFY( p == nullptr ); - - return 0; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/char/1.cc b/gdb/unittests/basic_string_view/operations/find/char/1.cc deleted file mode 100644 index 79706e05aca..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/1.cc +++ /dev/null @@ -1,168 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -namespace operations_find_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type npos = gdb::string_view::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const gdb::string_view str01("mavericks, santa cruz"); - gdb::string_view str02(str_lit01); - gdb::string_view str03("s, s"); - gdb::string_view str04; - - // size_type find(const string_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const char* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const char* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(char c, size_type pos = 0) const; - csz01 = str01.find('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find('/'); - VERIFY( csz01 == npos ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test02() -{ - typedef std::string_view::size_type csize_type; - typedef std::string_view::const_reference cref; - typedef std::string_view::reference ref; - csize_type npos = std::string_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const char str_lit01[] = "mave"; - const std::string_view str01("mavericks, santa cruz"); - std::string_view str02(str_lit01); - std::string_view str03("s, s"); - std::string_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find(const string_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const char* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const char* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(char c, size_type pos = 0) const; - csz01 = str01.find('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find('/'); - VERIFY( csz01 == npos ); - - return true; -} -#endif - -static int -main () -{ - test01(); -#ifndef GDB_STRING_VIEW - static_assert( test02() ); -#endif - - return 0; -} - -} // namespace operations_find_1 diff --git a/gdb/unittests/basic_string_view/operations/find/char/2.cc b/gdb/unittests/basic_string_view/operations/find/char/2.cc deleted file mode 100644 index c6bb97f10a6..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/2.cc +++ /dev/null @@ -1,166 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_of - -namespace operations_find_2 { - -static void -test02 () -{ - typedef gdb::string_view::size_type csize_type; - csize_type npos = gdb::string_view::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const gdb::string_view str01("mavericks, santa cruz"); - gdb::string_view str02(str_lit01); - gdb::string_view str03("s, s"); - gdb::string_view str04; - - // size_type find_first_of(const string_view&, size_type pos = 0) const; - gdb::string_view str05("xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_of('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test03() -{ - typedef std::string_view::size_type csize_type; - csize_type npos = std::string_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const char str_lit01[] = "mave"; - const std::string_view str01("mavericks, santa cruz"); - std::string_view str02(str_lit01); - std::string_view str03("s, s"); - std::string_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_of(const string_view&, size_type pos = 0) const; - std::string_view str05("xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_of('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - - return true; -} -#endif - -static int -main () -{ - test02(); -#ifndef GDB_STRING_VIEW - static_assert( test03() ); -#endif - - return 0; -} - -} // namespace operations_find_2 { diff --git a/gdb/unittests/basic_string_view/operations/find/char/3.cc b/gdb/unittests/basic_string_view/operations/find/char/3.cc deleted file mode 100644 index 078fda35d45..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/3.cc +++ /dev/null @@ -1,166 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_not_of - -namespace operations_find_3 { - -static void -test03 () -{ - typedef gdb::string_view::size_type csize_type; - csize_type npos = gdb::string_view::npos; - csize_type csz01; - - const gdb::string_view str01("Bob Rock, per me"); - const char str_lit01[] = "Bob Rock"; - gdb::string_view str02("ovvero Trivi"); - gdb::string_view str03(str_lit01); - gdb::string_view str04; - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of('B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of('o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of('z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of('S'); - VERIFY( csz01 == npos ); -} - -#ifndef GDB_STRING_VIEW -constexpr bool -test04() -{ - typedef std::string_view::size_type csize_type; - csize_type npos = std::string_view::npos; - csize_type csz01 = 0; - - const std::string_view str01("Bob Rock, per me"); - const char str_lit01[] = "Bob Rock"; - std::string_view str02("ovvero Trivi"); - std::string_view str03(str_lit01); - std::string_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of('B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of('o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of('z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of('S'); - VERIFY( csz01 == npos ); - - return true; -} -#endif - -static int -main () -{ - test03(); -#ifndef GDB_STRING_VIEW - static_assert( test04() ); -#endif - - return 0; -} - -} // namespace operations_find_3 diff --git a/gdb/unittests/basic_string_view/operations/find/char/4.cc b/gdb/unittests/basic_string_view/operations/find/char/4.cc deleted file mode 100644 index 9e19c01030d..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/char/4.cc +++ /dev/null @@ -1,45 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -namespace operations_find_4 { - -// libstdc++/31401 -static void -test01() -{ - typedef gdb::string_view::size_type csize_type; - csize_type npos = gdb::string_view::npos; - - gdb::string_view use = "anu"; - csize_type pos1 = use.find("a", npos); - - VERIFY( pos1 == npos ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_find_4 diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc deleted file mode 100644 index 08e9e7249c8..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc +++ /dev/null @@ -1,163 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type npos = std::wstring_view::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - - // size_type find(const wstring_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(wchar_t c, size_type pos = 0) const; - csz01 = str01.find(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find(L'/'); - VERIFY( csz01 == npos ); -} - -constexpr bool -test02() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type npos = std::wstring_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find(const wstring_view&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(wchar_t c, size_type pos = 0) const; - csz01 = str01.find(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find(L'/'); - VERIFY( csz01 == npos ); - - return true; -} - -int -main() -{ - test01(); - static_assert( test02() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc deleted file mode 100644 index fa38fe8e79c..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc +++ /dev/null @@ -1,161 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_of - -#include -#include - -void -test02() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - - // size_type find_first_of(const wstring_view&, size_type pos = 0) const; - std::wstring_view str05(L"xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(wchar_t c, size_type pos = 0) const; - csz01 = str01.find_first_of(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); -} - -constexpr bool -test04() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01 = 0, csz02 = 0; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_of(const wstring_view&, size_type pos = 0) const; - std::wstring_view str05(L"xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(wchar_t c, size_type pos = 0) const; - csz01 = str01.find_first_of(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - - return true; -} - -int -main() -{ - test02(); - static_assert( test04() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc deleted file mode 100644 index 93a238c3865..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc +++ /dev/null @@ -1,161 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find_first_not_of - -#include -#include - -void -test03() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01; - - const std::wstring_view str01(L"Bob Rock, per me"); - const wchar_t str_lit01[] = L"Bob Rock"; - std::wstring_view str02(L"ovvero Trivi"); - std::wstring_view str03(str_lit01); - std::wstring_view str04; - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of(L'B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of(L'o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of(L'z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of(L'S'); - VERIFY( csz01 == npos ); -} - -constexpr bool -test04() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - csize_type csz01 = 0; - - const std::wstring_view str01(L"Bob Rock, per me"); - const wchar_t str_lit01[] = L"Bob Rock"; - std::wstring_view str02(L"ovvero Trivi"); - std::wstring_view str03(str_lit01); - std::wstring_view str04; - -#undef VERIFY -#define VERIFY(x) if(!(x)) return false - - // size_type find_first_not_of(const string_view&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of(L'B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of(L'o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of(L'z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of(L'S'); - VERIFY( csz01 == npos ); - - return true; -} - -int -main() -{ - test03(); - static_assert( test04() ); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc deleted file mode 100644 index 7b484bd6b9b..00000000000 --- a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc +++ /dev/null @@ -1,44 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view find - -#include -#include - -// libstdc++/31401 -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - csize_type npos = std::wstring_view::npos; - - std::wstring_view use = L"anu"; - csize_type pos1 = use.find(L"a", npos); - - VERIFY( pos1 == npos ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc b/gdb/unittests/basic_string_view/operations/rfind/char/1.cc deleted file mode 100644 index b764cd959ab..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc +++ /dev/null @@ -1,95 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace operations_rfind_1 { - -// basic_string_view rfind - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type npos = gdb::string_view::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const gdb::string_view str01("mavericks, santa cruz"); - gdb::string_view str02(str_lit01); - gdb::string_view str03("s, s"); - gdb::string_view str04; - - // size_type rfind(const string_view&, size_type pos = 0) const; - csz01 = str01.rfind(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str01, 4); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02,3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str03); - VERIFY( csz01 == 8 ); - csz01 = str01.rfind(str03, 3); - VERIFY( csz01 == npos ); - csz01 = str01.rfind(str03, 12); - VERIFY( csz01 == 8 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.rfind(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.rfind(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.rfind(str04, str01.size()+1); - VERIFY( csz01 == str01.size() ); - - // size_type rfind(const char* s, size_type pos, size_type n) const; - csz01 = str01.rfind(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type rfind(const char* s, size_type pos = 0) const; - csz01 = str01.rfind(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3); - VERIFY( csz01 == 0 ); - - // size_type rfind(char c, size_type pos = 0) const; - csz01 = str01.rfind('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.rfind('/'); - VERIFY( csz01 == npos ); -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_rfind_1 diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc b/gdb/unittests/basic_string_view/operations/rfind/char/2.cc deleted file mode 100644 index 915a111fbcc..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc +++ /dev/null @@ -1,53 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace operations_rfind_2 { - -// basic_string_view::find_last_of - -static void -test02 () -{ - gdb::string_view z("ab"); - gdb::string_view::size_type pos; - pos = z.find_last_of("ab"); - VERIFY( pos == 1 ); - pos = z.find_last_of("Xa"); - VERIFY( pos == 0 ); - pos = z.find_last_of("Xb"); - VERIFY( pos == 1 ); - pos = z.find_last_of("XYZ"); - VERIFY( pos == gdb::string_view::npos ); - pos = z.find_last_of('a'); - VERIFY( pos == 0 ); - pos = z.find_last_of('b'); - VERIFY( pos == 1 ); - pos = z.find_last_of('X'); - VERIFY( pos == gdb::string_view::npos ); -} - -static int -main () -{ - test02(); - - return 0; -} - -} // namespace operations_rfind_2 diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc b/gdb/unittests/basic_string_view/operations/rfind/char/3.cc deleted file mode 100644 index a15debf97ec..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc +++ /dev/null @@ -1,68 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -namespace operations_rfind_3 { - -// basic_string_view::find_last_not_of - -static void -test03 () -{ - typedef gdb::string_view::size_type csize_type; - gdb::string_view::size_type pos; - csize_type npos = gdb::string_view::npos; - - gdb::string_view x; - pos = x.find_last_not_of('X'); - VERIFY( pos == npos ); - pos = x.find_last_not_of("XYZ"); - VERIFY( pos == npos ); - - gdb::string_view y("a"); - pos = y.find_last_not_of('X'); - VERIFY( pos == 0 ); - pos = y.find_last_not_of('a'); - VERIFY( pos == npos ); - pos = y.find_last_not_of("XYZ"); - VERIFY( pos == 0 ); - pos = y.find_last_not_of("a"); - VERIFY( pos == npos ); - - gdb::string_view z("ab"); - pos = z.find_last_not_of('X'); - VERIFY( pos == 1 ); - pos = z.find_last_not_of("XYZ"); - VERIFY( pos == 1 ); - pos = z.find_last_not_of('b'); - VERIFY( pos == 0 ); - pos = z.find_last_not_of("Xb"); - VERIFY( pos == 0 ); - pos = z.find_last_not_of("Xa"); - VERIFY( pos == 1 ); -} - -static int -main () -{ - test03(); - - return 0; -} - -} // namespace operations_rfind_3 diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc deleted file mode 100644 index d5ad681eded..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc +++ /dev/null @@ -1,94 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// basic_string_view rfind - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type npos = std::wstring_view::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring_view str01(L"mavericks, santa cruz"); - std::wstring_view str02(str_lit01); - std::wstring_view str03(L"s, s"); - std::wstring_view str04; - - // size_type rfind(const wstring_view&, size_type pos = 0) const; - csz01 = str01.rfind(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str01, 4); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02,3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str03); - VERIFY( csz01 == 8 ); - csz01 = str01.rfind(str03, 3); - VERIFY( csz01 == npos ); - csz01 = str01.rfind(str03, 12); - VERIFY( csz01 == 8 ); - - // An empty string_view consists of no characters - // therefore it should be found at every point in a string_view, - // except beyond the end - csz01 = str01.rfind(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.rfind(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.rfind(str04, str01.size()+1); - VERIFY( csz01 == str01.size() ); - - // size_type rfind(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.rfind(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type rfind(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.rfind(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3); - VERIFY( csz01 == 0 ); - - // size_type rfind(wchar_t c, size_type pos = 0) const; - csz01 = str01.rfind(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.rfind(L'/'); - VERIFY( csz01 == npos ); -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc deleted file mode 100644 index 6f3dc744ad7..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc +++ /dev/null @@ -1,52 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// basic_string_view::find_last_of - -void -test02() -{ - std::wstring_view::size_type pos; - std::wstring_view z(L"ab"); - pos = z.find_last_of(L"ab"); - VERIFY( pos == 1 ); - pos = z.find_last_of(L"Xa"); - VERIFY( pos == 0 ); - pos = z.find_last_of(L"Xb"); - VERIFY( pos == 1 ); - pos = z.find_last_of(L"XYZ"); - VERIFY( pos == std::wstring_view::npos ); - pos = z.find_last_of(L'a'); - VERIFY( pos == 0 ); - pos = z.find_last_of(L'b'); - VERIFY( pos == 1 ); - pos = z.find_last_of(L'X'); - VERIFY( pos == std::wstring_view::npos ); -} - -int -main() -{ - test02(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc deleted file mode 100644 index b67f8ec08af..00000000000 --- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc +++ /dev/null @@ -1,66 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// basic_string_view::find_last_not_of - -void -test03() -{ - typedef std::wstring_view::size_type csize_type; - std::wstring_view::size_type pos; - csize_type npos = std::wstring_view::npos; - - std::wstring_view x; - pos = x.find_last_not_of(L'X'); - VERIFY( pos == npos ); - pos = x.find_last_not_of(L"XYZ"); - VERIFY( pos == npos ); - - std::wstring_view y(L"a"); - pos = y.find_last_not_of(L'X'); - VERIFY( pos == 0 ); - pos = y.find_last_not_of(L'a'); - VERIFY( pos == npos ); - pos = y.find_last_not_of(L"XYZ"); - VERIFY( pos == 0 ); - pos = y.find_last_not_of(L"a"); - VERIFY( pos == npos ); - - std::wstring_view z(L"ab"); - pos = z.find_last_not_of(L'X'); - VERIFY( pos == 1 ); - pos = z.find_last_not_of(L"XYZ"); - VERIFY( pos == 1 ); - pos = z.find_last_not_of(L'b'); - VERIFY( pos == 0 ); - pos = z.find_last_not_of(L"Xb"); - VERIFY( pos == 0 ); - pos = z.find_last_not_of(L"Xa"); - VERIFY( pos == 1 ); -} -int -main() -{ - test03(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc b/gdb/unittests/basic_string_view/operations/string_conversion/1.cc deleted file mode 100644 index 33784231d8d..00000000000 --- a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc +++ /dev/null @@ -1,51 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2014-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::to_string - -#include -#include -#include -#include -#include - -void -test01() -{ - const char str_lit[] = "123456789A"; - const std::string_view sv(str_lit); - char buffer[4] = { 0 }; - - std::string s1{sv}; - VERIFY( s1 == str_lit ); - using test_alloc = __gnu_test::tracker_allocator; - std::basic_string, test_alloc> - s2{sv, test_alloc{}}; - static_assert( std::is_same::value, - "to_string() uses custom allocator" ); - VERIFY( std::equal(s1.begin(), s1.end(), s2.begin(), s2.end()) ); - auto s3 = static_cast(sv); - VERIFY( s3 == s1 ); -} - -int -main() -{ - test01(); -} diff --git a/gdb/unittests/basic_string_view/operations/substr/char/1.cc b/gdb/unittests/basic_string_view/operations/substr/char/1.cc deleted file mode 100644 index 19454466699..00000000000 --- a/gdb/unittests/basic_string_view/operations/substr/char/1.cc +++ /dev/null @@ -1,79 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::substr - -namespace operations_substr_1 { - -static void -test01 () -{ - typedef gdb::string_view::size_type csize_type; - typedef gdb::string_view::const_reference cref; - typedef gdb::string_view::reference ref; - csize_type csz01; - - const char str_lit01[] = "rockaway, pacifica"; - const gdb::string_view str01(str_lit01); - gdb::string_view str02; - - // basic_string_view - // substr(size_type pos = 0, size_type n = npos) const; - csz01 = str01.size(); - str02 = str01.substr(0, 1); - VERIFY( str02 == "r" ); - str02 = str01.substr(10); - VERIFY( str02 == "pacifica" ); - - try - { - str02 = str01.substr(csz01 + 1); - VERIFY( false ); - } - catch(gdb_exception& fail) - { - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } - - try - { - str02 = str01.substr(csz01); - VERIFY( str02.size() == 0 ); - VERIFY( str02.begin() == str01.end() ); - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } -} - -static int -main () -{ - test01(); - - return 0; -} - -} // namespace operations_substr_1 diff --git a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc deleted file mode 100644 index bfe79ac7a55..00000000000 --- a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc +++ /dev/null @@ -1,79 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string_view::substr - -#include -#include -#include - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - csize_type csz01; - - const wchar_t str_lit01[] = L"rockaway, pacifica"; - const std::wstring_view str01(str_lit01); - std::wstring_view str02; - - // basic_string_view - // substr(size_type pos = 0, size_type n = npos) const; - csz01 = str01.size(); - str02 = str01.substr(0, 1); - VERIFY( str02 == L"r" ); - str02 = str01.substr(10); - VERIFY( str02 == L"pacifica" ); - - try - { - str02 = str01.substr(csz01 + 1); - VERIFY( false ); - } - catch(std::out_of_range& fail) - { - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } - - try - { - str02 = str01.substr(csz01); - VERIFY( str02.size() == 0 ); - VERIFY( str02.begin() == str01.end() ); - VERIFY( true ); - } - catch(...) - { - VERIFY( false ); - } -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/operators/char/2.cc b/gdb/unittests/basic_string_view/operators/char/2.cc deleted file mode 100644 index 30e557f4599..00000000000 --- a/gdb/unittests/basic_string_view/operators/char/2.cc +++ /dev/null @@ -1,373 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// basic_string non-member functions - -// operator== -/* -template - bool operator==(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator==(const charT* lhs, - const basic_string& rhs); - -template - bool operator==(const basic_string& lhs, - const charT* rhs); -*/ - -// operator!= -/* -template - bool operator!=(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator!=(const charT* lhs, - const basic_string& rhs); - -template - bool operator!=(const basic_string& lhs, - const charT* rhs); -*/ - -// operator< -/* -template - bool operator< (const basic_string& lhs, - const basic_string& rhs); - -template - bool operator< (const basic_string& lhs, - const charT* rhs); - -template - bool operator< (const charT* lhs, - const basic_string& rhs); -*/ - -// operator> -/* -template - bool operator> (const basic_string& lhs, - const basic_string& rhs); - -template - bool operator> (const basic_string& lhs, - const charT* rhs); - -template - bool operator> (const charT* lhs, - const basic_string& rhs); -*/ - -// operator<= -/* -template - bool operator<=(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator<=(const basic_string& lhs, - const charT* rhs); - -template - bool operator<=(const charT* lhs, - const basic_string& rhs); -*/ - -// operator>= -/* -template - bool operator>=(const basic_string& lhs, - const basic_string& rhs); - -template - bool operator>=(const basic_string& lhs, - const charT* rhs); - -template - bool operator>=(const charT* lhs, - const basic_string& rhs); -*/ - -namespace operators_2 { - -static void -test01() -{ - gdb::string_view str_0("costa rica"); - gdb::string_view str_1("costa marbella"); - gdb::string_view str_2("cost"); - gdb::string_view str_3("costa ricans"); - gdb::string_view str_4; - - str_4 = str_0; - //comparisons between string objects - VERIFY( !(str_0 == str_1) ); - VERIFY( !(str_0 == str_2) ); - VERIFY( !(str_0 == str_3) ); - VERIFY( !(str_1 == str_0) ); - VERIFY( !(str_2 == str_0) ); - VERIFY( !(str_3 == str_0) ); - VERIFY( str_4 == str_0 ); - VERIFY( str_0 == str_4 ); - - VERIFY( str_0 != str_1 ); - VERIFY( str_0 != str_2 ); - VERIFY( str_0 != str_3 ); - VERIFY( str_1 != str_0 ); - VERIFY( str_2 != str_0 ); - VERIFY( str_3 != str_0 ); - VERIFY( !(str_0 != str_4) ); - VERIFY( !(str_4 != str_0) ); - - VERIFY( str_0 > str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m "costa marbella" ); //true cuz r>m - VERIFY( str_0 > "cost" ); - VERIFY( !(str_0 > "costa ricans") ); - VERIFY( !("costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( "costa ricans" > str_0 ); - VERIFY( !("costa rica" > str_0) ); - VERIFY( !(str_0 > "costa rica") ); - - VERIFY( !(str_0 < "costa marbella") );//false cuz r>m - VERIFY( !(str_0 < "cost") ); - VERIFY( str_0 < "costa ricans" ); - VERIFY( "costa marbella" < str_0 );//true cuz m= "costa marbella" );//true cuz r>m - VERIFY( str_0 >= "cost" ); - VERIFY( !(str_0 >= "costa ricans") ); - VERIFY( !("costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( "costa ricans" >= str_0 ); - VERIFY( "costa rica" >= str_0 ); - VERIFY( str_0 >= "costa rica" ); - - VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= "cost") ); - VERIFY( str_0 <= "costa ricans" ); - VERIFY( "costa marbella" <= str_0 );//true cuz m str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m "costa marbella" ); //true cuz r>m - VERIFY( str_0 > "cost" ); - VERIFY( !(str_0 > "costa ricans") ); - VERIFY( !("costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( "costa ricans" > str_0 ); - VERIFY( !("costa rica" > str_0) ); - VERIFY( !(str_0 > "costa rica") ); - - VERIFY( !(str_0 < "costa marbella") );//false cuz r>m - VERIFY( !(str_0 < "cost") ); - VERIFY( str_0 < "costa ricans" ); - VERIFY( "costa marbella" < str_0 );//true cuz m= "costa marbella" );//true cuz r>m - VERIFY( str_0 >= "cost" ); - VERIFY( !(str_0 >= "costa ricans") ); - VERIFY( !("costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( "costa ricans" >= str_0 ); - VERIFY( "costa rica" >= str_0 ); - VERIFY( str_0 >= "costa rica" ); - - VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= "cost") ); - VERIFY( str_0 <= "costa ricans" ); - VERIFY( "costa marbella" <= str_0 );//true cuz m. - -// basic_string_view non-member functions - -// operator== -/* -template - bool operator==(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator==(const charT* lhs, - const basic_string_view& rhs); - -template - bool operator==(const basic_string_view& lhs, - const charT* rhs); -*/ - -// operator!= -/* -template - bool operator!=(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator!=(const charT* lhs, - const basic_string_view& rhs); - -template - bool operator!=(const basic_string_view& lhs, - const charT* rhs); -*/ - -// operator< -/* -template - bool operator< (const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator< (const basic_string_view& lhs, - const charT* rhs); - -template - bool operator< (const charT* lhs, - const basic_string_view& rhs); -*/ - -// operator> -/* -template - bool operator> (const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator> (const basic_string_view& lhs, - const charT* rhs); - -template - bool operator> (const charT* lhs, - const basic_string_view& rhs); -*/ - -// operator<= -/* -template - bool operator<=(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator<=(const basic_string_view& lhs, - const charT* rhs); - -template - bool operator<=(const charT* lhs, - const basic_string_view& rhs); -*/ - -// operator>= -/* -template - bool operator>=(const basic_string_view& lhs, - const basic_string_view& rhs); - -template - bool operator>=(const basic_string_view& lhs, - const charT* rhs); - -template - bool operator>=(const charT* lhs, - const basic_string_view& rhs); -*/ - -#include -#include - -void -test01() -{ - std::wstring_view str_0(L"costa rica"); - std::wstring_view str_1(L"costa marbella"); - std::wstring_view str_2(L"cost"); - std::wstring_view str_3(L"costa ricans"); - std::wstring_view str_4; - - str_4 = str_0; - //comparisons between string_view objects - VERIFY( !(str_0 == str_1) ); - VERIFY( !(str_0 == str_2) ); - VERIFY( !(str_0 == str_3) ); - VERIFY( !(str_1 == str_0) ); - VERIFY( !(str_2 == str_0) ); - VERIFY( !(str_3 == str_0) ); - VERIFY( str_4 == str_0 ); - VERIFY( str_0 == str_4 ); - - VERIFY( str_0 != str_1 ); - VERIFY( str_0 != str_2 ); - VERIFY( str_0 != str_3 ); - VERIFY( str_1 != str_0 ); - VERIFY( str_2 != str_0 ); - VERIFY( str_3 != str_0 ); - VERIFY( !(str_0 != str_4) ); - VERIFY( !(str_4 != str_0) ); - - VERIFY( str_0 > str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m L"costa marbella" ); //true cuz r>m - VERIFY( str_0 > L"cost" ); - VERIFY( !(str_0 > L"costa ricans") ); - VERIFY( !(L"costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( L"costa ricans" > str_0 ); - VERIFY( !(L"costa rica" > str_0) ); - VERIFY( !(str_0 > L"costa rica") ); - - VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 < L"cost") ); - VERIFY( str_0 < L"costa ricans" ); - VERIFY( L"costa marbella" < str_0 );//true cuz m= L"costa marbella" );//true cuz r>m - VERIFY( str_0 >= L"cost" ); - VERIFY( !(str_0 >= L"costa ricans") ); - VERIFY( !(L"costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( L"costa ricans" >= str_0 ); - VERIFY( L"costa rica" >= str_0 ); - VERIFY( str_0 >= L"costa rica" ); - - VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= L"cost") ); - VERIFY( str_0 <= L"costa ricans" ); - VERIFY( L"costa marbella" <= str_0 );//true cuz m str_1 ); //true cuz r>m - VERIFY( str_0 > str_2 ); - VERIFY( !(str_0 > str_3) ); - VERIFY( !(str_1 > str_0) ); //false cuz m str_0) ); - VERIFY( str_3 > str_0 ); - VERIFY( !(str_0 > str_4) ); - VERIFY( !(str_4 > str_0) ); - - VERIFY( !(str_0 < str_1) ); //false cuz r>m - VERIFY( !(str_0 < str_2) ); - VERIFY( str_0 < str_3 ); - VERIFY( str_1 < str_0 ); //true cuz m= str_1 ); //true cuz r>m - VERIFY( str_0 >= str_2 ); - VERIFY( !(str_0 >= str_3) ); - VERIFY( !(str_1 >= str_0) );//false cuz m= str_0) ); - VERIFY( str_3 >= str_0 ); - VERIFY( str_0 >= str_4 ); - VERIFY( str_4 >= str_0 ); - - VERIFY( !(str_0 <= str_1) );//false cuz r>m - VERIFY( !(str_0 <= str_2) ); - VERIFY( str_0 <= str_3 ); - VERIFY( str_1 <= str_0 );//true cuz m L"costa marbella" ); //true cuz r>m - VERIFY( str_0 > L"cost" ); - VERIFY( !(str_0 > L"costa ricans") ); - VERIFY( !(L"costa marbella" > str_0) );//false cuz m str_0) ); - VERIFY( L"costa ricans" > str_0 ); - VERIFY( !(L"costa rica" > str_0) ); - VERIFY( !(str_0 > L"costa rica") ); - - VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 < L"cost") ); - VERIFY( str_0 < L"costa ricans" ); - VERIFY( L"costa marbella" < str_0 );//true cuz m= L"costa marbella" );//true cuz r>m - VERIFY( str_0 >= L"cost" ); - VERIFY( !(str_0 >= L"costa ricans") ); - VERIFY( !(L"costa marbella" >= str_0) );//false cuz m= str_0) ); - VERIFY( L"costa ricans" >= str_0 ); - VERIFY( L"costa rica" >= str_0 ); - VERIFY( str_0 >= L"costa rica" ); - - VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m - VERIFY( !(str_0 <= L"cost") ); - VERIFY( str_0 <= L"costa ricans" ); - VERIFY( L"costa marbella" <= str_0 );//true cuz m. - -// C++17 27.7, range access [iterator.range] - -#include - -void -test01() -{ - std::string_view s("Hello, World!"); - std::begin(s); - std::end(s); - std::rbegin(s); - std::rend(s); -} - -void -test02() -{ - constexpr std::string_view s("Hello, World!"); - [[maybe_unused]] constexpr auto b = std::begin(s); - [[maybe_unused]] constexpr auto e = std::end(s); - [[maybe_unused]] constexpr auto cb = std::cbegin(s); - [[maybe_unused]] constexpr auto ce = std::cend(s); - [[maybe_unused]] constexpr auto rb = std::rbegin(s); - [[maybe_unused]] constexpr auto re = std::rend(s); - [[maybe_unused]] constexpr auto crb = std::crbegin(s); - [[maybe_unused]] constexpr auto cre = std::crend(s); -} diff --git a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc deleted file mode 100644 index 68b6b1c8c96..00000000000 --- a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc +++ /dev/null @@ -1,47 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// C++17 27.7, range access [iterator.range] - -#include - -void -test01() -{ - std::wstring_view ws(L"Hello, World!"); - std::begin(ws); - std::end(ws); - std::rbegin(ws); - std::rend(ws); -} - -void -test02() -{ - constexpr std::wstring_view ws(L"Hello, World!"); - [[maybe_unused]] constexpr auto b = std::begin(ws); - [[maybe_unused]] constexpr auto e = std::end(ws); - [[maybe_unused]] constexpr auto cb = std::cbegin(ws); - [[maybe_unused]] constexpr auto ce = std::cend(ws); - [[maybe_unused]] constexpr auto rb = std::rbegin(ws); - [[maybe_unused]] constexpr auto re = std::rend(ws); - [[maybe_unused]] constexpr auto crb = std::crbegin(ws); - [[maybe_unused]] constexpr auto cre = std::crend(ws); -} diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc deleted file mode 100644 index afea9946bf4..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - - -// This file tests explicit instantiation of basic_string - -#include - -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -template class std::basic_string_view>; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc deleted file mode 100644 index 7db0e922257..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc +++ /dev/null @@ -1,23 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc deleted file mode 100644 index 5eb588fce32..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc +++ /dev/null @@ -1,24 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } -// { dg-require-cstdint "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc deleted file mode 100644 index 2c6460277dd..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc +++ /dev/null @@ -1,24 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } -// { dg-require-cstdint "" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc deleted file mode 100644 index 213615f222e..00000000000 --- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc +++ /dev/null @@ -1,23 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this library; see the file COPYING3. If not see -// . - -#include - -template class std::basic_string_view; diff --git a/gdb/unittests/basic_string_view/requirements/typedefs.cc b/gdb/unittests/basic_string_view/requirements/typedefs.cc deleted file mode 100644 index 2bb08abfd25..00000000000 --- a/gdb/unittests/basic_string_view/requirements/typedefs.cc +++ /dev/null @@ -1,47 +0,0 @@ - -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -namespace __gnu_test -{ - template - struct traits> : public traits_base - { - typedef std::true_type is_container; - typedef std::true_type is_reversible; - }; -} - -#include - -// Check container for required typedefs. - -__gnu_test::basic_types t1b; -__gnu_test::reversible_types t1r; -typedef typename std::string_view::traits_type traits_type1; - -#ifdef _GLIBCXX_USE_WCHAR_T -__gnu_test::basic_types t2b; -__gnu_test::reversible_types t2r; -typedef typename std::wstring_view::traits_type traits_type2; -#endif diff --git a/gdb/unittests/basic_string_view/typedefs.cc b/gdb/unittests/basic_string_view/typedefs.cc deleted file mode 100644 index c4222bf8ebf..00000000000 --- a/gdb/unittests/basic_string_view/typedefs.cc +++ /dev/null @@ -1,36 +0,0 @@ -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -// Copyright (C) 2014-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include - -template - using check1_t = std::basic_string_view; - -using check2_t = std::string_view; - -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 -using check3_t = std::u16string_view; -using check4_t = std::u32string_view; -#endif - -#ifdef _GLIBCXX_USE_WCHAR_T -using check5_t = std::wstring_view; -#endif - diff --git a/gdb/unittests/basic_string_view/types/1.cc b/gdb/unittests/basic_string_view/types/1.cc deleted file mode 100644 index d742df23a44..00000000000 --- a/gdb/unittests/basic_string_view/types/1.cc +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . -// - -// { dg-options "-std=gnu++17" } -// { dg-do compile } - -#include - -struct T -{ - typedef std::string_view String_view; - typedef String_view::iterator iterator; - typedef String_view::const_iterator const_iterator; - - char t(iterator f) { return *f; } - char t(const_iterator f) const { return *f; } -}; - -void -f() -{ - std::string_view s; - T t; - T::const_iterator i = s.begin(); - - t.t(i); -} diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c deleted file mode 100644 index cf43d29502c..00000000000 --- a/gdb/unittests/string_view-selftests.c +++ /dev/null @@ -1,193 +0,0 @@ -/* Self tests for string_view for GDB, the GNU debugger. - - Copyright (C) 2018-2023 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* No need to test string_view if we're using C++17, since we're going to use - the "real" version. */ -#if __cplusplus < 201703L - -#define GNULIB_NAMESPACE gnulib - -#include "diagnostics.h" - -/* Since this file uses GNULIB_NAMESPACE, some code defined in headers ends up - using system functions rather than gnulib replacements. This is not really - a problem for this test, but it generates some warnings with Clang, silence - them. */ -DIAGNOSTIC_PUSH -DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS - -#include "defs.h" -#include "gdbsupport/selftest.h" -#include "gdbsupport/gdb_string_view.h" - -/* Used by the included .cc files below. Included here because the - included test files are wrapped in a namespace. */ -#include -#include -#include -#include - -DIAGNOSTIC_POP - -/* libstdc++'s testsuite uses VERIFY. */ -#define VERIFY SELF_CHECK - -/* Used to disable testing features not supported by - gdb::string_view. */ -#define GDB_STRING_VIEW - -namespace selftests { -namespace string_view { - -/* The actual tests live in separate files, which were originally - copied over from libstdc++'s testsuite. To preserve the structure - and help with comparison with the original tests, the file names - have been preserved, and only minimal modification was done to have - them compile against gdb::string_view instead of std::string_view: - - - std::string_view->gdb::string_view, etc. - - ATTRIBUTE_UNUSED in a few places - - wrap each file in a namespace so they can all be compiled as a - single unit. - - libstdc++'s license and formatting style was preserved. -*/ - -#include "basic_string_view/capacity/1.cc" -#include "basic_string_view/cons/char/1.cc" -#include "basic_string_view/cons/char/2.cc" -#include "basic_string_view/cons/char/3.cc" -#include "basic_string_view/element_access/char/1.cc" -#include "basic_string_view/element_access/char/empty.cc" -#include "basic_string_view/element_access/char/front_back.cc" -#include "basic_string_view/inserters/char/2.cc" -#include "basic_string_view/modifiers/remove_prefix/char/1.cc" -#include "basic_string_view/modifiers/remove_suffix/char/1.cc" -#include "basic_string_view/modifiers/swap/char/1.cc" -#include "basic_string_view/operations/compare/char/1.cc" -#include "basic_string_view/operations/compare/char/13650.cc" -#include "basic_string_view/operations/copy/char/1.cc" -#include "basic_string_view/operations/data/char/1.cc" -#include "basic_string_view/operations/find/char/1.cc" -#include "basic_string_view/operations/find/char/2.cc" -#include "basic_string_view/operations/find/char/3.cc" -#include "basic_string_view/operations/find/char/4.cc" -#include "basic_string_view/operations/rfind/char/1.cc" -#include "basic_string_view/operations/rfind/char/2.cc" -#include "basic_string_view/operations/rfind/char/3.cc" -#include "basic_string_view/operations/substr/char/1.cc" -#include "basic_string_view/operators/char/2.cc" - -static void -run_tests () -{ - capacity_1::main (); - cons_1::main (); - cons_2::main (); - cons_3::main (); - element_access_1::main (); - element_access_empty::main (); - element_access_front_back::main (); - inserters_2::main (); - modifiers_remove_prefix::main (); - modifiers_remove_suffix::main (); - modifiers_swap::test01 (); - operations_compare_1::main (); - operations_compare_13650::main (); - operations_copy_1::main (); - operations_data_1::main (); - operations_find_1::main (); - operations_find_2::main (); - operations_find_3::main (); - operations_find_4::main (); - operations_rfind_1::main (); - operations_rfind_2::main (); - operations_rfind_3::main (); - operations_substr_1::main (); - operators_2::main (); - - constexpr gdb::string_view sv_empty; - SELF_CHECK (sv_empty.empty ()); - - std::string std_string = "fika"; - gdb::string_view sv1 (std_string); - SELF_CHECK (sv1 == "fika"); - - constexpr const char *fika = "fika"; - gdb::string_view sv2 (fika); - SELF_CHECK (sv2 == "fika"); - - constexpr gdb::string_view sv3 (fika, 3); - SELF_CHECK (sv3 == "fik"); - - constexpr gdb::string_view sv4 (sv3); - SELF_CHECK (sv4 == "fik"); - - constexpr gdb::string_view::iterator it_begin = sv4.begin (); - static_assert (*it_begin == 'f', ""); - - constexpr gdb::string_view::iterator it_end = sv4.end (); - static_assert (*it_end == 'a', ""); - - const gdb::string_view::reverse_iterator it_rbegin = sv4.rbegin (); - SELF_CHECK (*it_rbegin == 'k'); - - const gdb::string_view::reverse_iterator it_rend = sv4.rend (); - SELF_CHECK (*(it_rend - 1) == 'f'); - - constexpr gdb::string_view::size_type size = sv4.size (); - static_assert (size == 3, ""); - - constexpr gdb::string_view::size_type length = sv4.length (); - static_assert (length == 3, ""); - - constexpr gdb::string_view::size_type max_size = sv4.max_size (); - static_assert (max_size > 0, ""); - - constexpr bool empty = sv4.empty (); - static_assert (!empty, ""); - - constexpr char c1 = sv4[1]; - static_assert (c1 == 'i', ""); - - constexpr char c2 = sv4.at (2); - static_assert (c2 == 'k', ""); - - constexpr char front = sv4.front (); - static_assert (front == 'f', ""); - - constexpr char back = sv4.back (); - static_assert (back == 'k', ""); - - constexpr const char *data = sv4.data (); - static_assert (data == fika, ""); -} - -} /* namespace string_view */ -} /* namespace selftests */ - -#endif /* __cplusplus < 201703L */ - -void _initialize_string_view_selftests (); -void -_initialize_string_view_selftests () -{ -#if defined(GDB_STRING_VIEW) - selftests::register_test ("string_view", selftests::string_view::run_tests); -#endif -} diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h deleted file mode 100644 index cf7af623327..00000000000 --- a/gdbsupport/gdb_string_view.h +++ /dev/null @@ -1,566 +0,0 @@ -// Components for manipulating non-owning sequences of characters -*- C++ -*- - - -#ifndef COMMON_GDB_STRING_VIEW_H -#define COMMON_GDB_STRING_VIEW_H - -// Note: This file has been stolen from the gcc repo -// (libstdc++-v3/include/experimental/string_view) and has local modifications. - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -// -// N3762 basic_string_view library -// - - -#if __cplusplus >= 201703L - -#include - -namespace gdb { - using string_view = std::string_view; -} /* namespace gdb */ - -#else /* __cplusplus < 201703L */ - -#include -#include -#include "gdb_assert.h" - -namespace gdb { - - /** - * @class basic_string_view - * @brief A non-owning reference to a string. - * - * @ingroup strings - * @ingroup sequences - * @ingroup experimental - * - * @tparam _CharT Type of character - * @tparam _Traits Traits for character type, defaults to - * char_traits<_CharT>. - * - * A basic_string_view looks like this: - * - * @code - * _CharT* _M_str - * size_t _M_len - * @endcode - */ - template> - class basic_string_view - { - public: - - // types - using traits_type = _Traits; - using value_type = _CharT; - using pointer = const _CharT*; - using const_pointer = const _CharT*; - using reference = const _CharT&; - using const_reference = const _CharT&; - using const_iterator = const _CharT*; - using iterator = const_iterator; - using const_reverse_iterator = std::reverse_iterator; - using reverse_iterator = const_reverse_iterator; - using size_type = size_t; - using difference_type = ptrdiff_t; - static constexpr size_type npos = size_type(-1); - - // [string.view.cons], construct/copy - - constexpr - basic_string_view() noexcept - : _M_len{0}, _M_str{nullptr} - { } - - constexpr basic_string_view(const basic_string_view&) noexcept = default; - - template - basic_string_view(const std::basic_string<_CharT, _Traits, - _Allocator>& __str) noexcept - : _M_len{__str.length()}, _M_str{__str.data()} - { } - - /*constexpr*/ basic_string_view(const _CharT* __str) - : _M_len{__str == nullptr ? 0 : traits_type::length(__str)}, - _M_str{__str} - { } - - constexpr basic_string_view(const _CharT* __str, size_type __len) - : _M_len{__len}, - _M_str{__str} - { } - - basic_string_view& - operator=(const basic_string_view&) noexcept = default; - - // [string.view.iterators], iterators - - constexpr const_iterator - begin() const noexcept - { return this->_M_str; } - - constexpr const_iterator - end() const noexcept - { return this->_M_str + this->_M_len; } - - constexpr const_iterator - cbegin() const noexcept - { return this->_M_str; } - - constexpr const_iterator - cend() const noexcept - { return this->_M_str + this->_M_len; } - - const_reverse_iterator - rbegin() const noexcept - { return const_reverse_iterator(this->end()); } - - const_reverse_iterator - rend() const noexcept - { return const_reverse_iterator(this->begin()); } - - const_reverse_iterator - crbegin() const noexcept - { return const_reverse_iterator(this->end()); } - - const_reverse_iterator - crend() const noexcept - { return const_reverse_iterator(this->begin()); } - - // [string.view.capacity], capacity - - constexpr size_type - size() const noexcept - { return this->_M_len; } - - constexpr size_type - length() const noexcept - { return _M_len; } - - constexpr size_type - max_size() const noexcept - { - return (npos - sizeof(size_type) - sizeof(void*)) - / sizeof(value_type) / 4; - } - - constexpr bool - empty() const noexcept - { return this->_M_len == 0; } - - // [string.view.access], element access - - constexpr const _CharT& - operator[](size_type __pos) const - { - // TODO: Assert to restore in a way compatible with the constexpr. - // __glibcxx_assert(__pos < this->_M_len); - return *(this->_M_str + __pos); - } - - constexpr const _CharT& - at(size_type __pos) const - { - return __pos < this->_M_len - ? *(this->_M_str + __pos) - : (error (_("basic_string_view::at: __pos " - "(which is %zu) >= this->size() " - "(which is %zu)"), - __pos, this->size()), - *this->_M_str); - } - - constexpr const _CharT& - front() const - { - // TODO: Assert to restore in a way compatible with the constexpr. - // __glibcxx_assert(this->_M_len > 0); - return *this->_M_str; - } - - constexpr const _CharT& - back() const - { - // TODO: Assert to restore in a way compatible with the constexpr. - // __glibcxx_assert(this->_M_len > 0); - return *(this->_M_str + this->_M_len - 1); - } - - constexpr const _CharT* - data() const noexcept - { return this->_M_str; } - - // [string.view.modifiers], modifiers: - - /*constexpr*/ void - remove_prefix(size_type __n) - { - gdb_assert (this->_M_len >= __n); - this->_M_str += __n; - this->_M_len -= __n; - } - - /*constexpr*/ void - remove_suffix(size_type __n) - { this->_M_len -= __n; } - - /*constexpr*/ void - swap(basic_string_view& __sv) noexcept - { - auto __tmp = *this; - *this = __sv; - __sv = __tmp; - } - - - // [string.view.ops], string operations: - - template - explicit operator std::basic_string<_CharT, _Traits, _Allocator>() const - { - return { this->_M_str, this->_M_len }; - } - - size_type - copy(_CharT* __str, size_type __n, size_type __pos = 0) const - { - gdb_assert (__str != nullptr || __n == 0); - if (__pos > this->_M_len) - error (_("basic_string_view::copy: __pos " - "(which is %zu) > this->size() " - "(which is %zu)"), - __pos, this->size()); - size_type __rlen{std::min(__n, size_type{this->_M_len - __pos})}; - for (auto __begin = this->_M_str + __pos, - __end = __begin + __rlen; __begin != __end;) - *__str++ = *__begin++; - return __rlen; - } - - - // [string.view.ops], string operations: - - /*constexpr*/ basic_string_view - substr(size_type __pos, size_type __n=npos) const - { - return __pos <= this->_M_len - ? basic_string_view{this->_M_str + __pos, - std::min(__n, size_type{this->_M_len - __pos})} - : (error (_("basic_string_view::substr: __pos " - "(which is %zu) > this->size() " - "(which is %zu)"), - __pos, this->size()), basic_string_view{}); - } - - /*constexpr*/ int - compare(basic_string_view __str) const noexcept - { - int __ret = traits_type::compare(this->_M_str, __str._M_str, - std::min(this->_M_len, __str._M_len)); - if (__ret == 0) - __ret = _S_compare(this->_M_len, __str._M_len); - return __ret; - } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, basic_string_view __str) const - { return this->substr(__pos1, __n1).compare(__str); } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, - basic_string_view __str, size_type __pos2, size_type __n2) const - { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); } - - /*constexpr*/ int - compare(const _CharT* __str) const noexcept - { return this->compare(basic_string_view{__str}); } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, const _CharT* __str) const - { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); } - - /*constexpr*/ int - compare(size_type __pos1, size_type __n1, - const _CharT* __str, size_type __n2) const - { - return this->substr(__pos1, __n1) - .compare(basic_string_view(__str, __n2)); - } - - /*constexpr*/ size_type - find(basic_string_view __str, size_type __pos = 0) const noexcept - { return this->find(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find(_CharT __c, size_type __pos=0) const noexcept; - - /*constexpr*/ size_type - find(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - - /*constexpr*/ size_type - find(const _CharT* __str, size_type __pos=0) const noexcept - { return this->find(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - rfind(basic_string_view __str, size_type __pos = npos) const noexcept - { return this->rfind(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - rfind(_CharT __c, size_type __pos = npos) const noexcept; - - /*constexpr*/ size_type - rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept; - - /*constexpr*/ size_type - rfind(const _CharT* __str, size_type __pos = npos) const noexcept - { return this->rfind(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept - { return this->find_first_of(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find_first_of(_CharT __c, size_type __pos = 0) const noexcept - { return this->find(__c, __pos); } - - /*constexpr*/ size_type - find_first_of(const _CharT* __str, size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept - { return this->find_first_of(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - find_last_of(basic_string_view __str, - size_type __pos = npos) const noexcept - { return this->find_last_of(__str._M_str, __pos, __str._M_len); } - - size_type - find_last_of(_CharT __c, size_type __pos=npos) const noexcept - { return this->rfind(__c, __pos); } - - /*constexpr*/ size_type - find_last_of(const _CharT* __str, size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept - { return this->find_last_of(__str, __pos, traits_type::length(__str)); } - - /*constexpr*/ size_type - find_first_not_of(basic_string_view __str, - size_type __pos = 0) const noexcept - { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept; - - /*constexpr*/ size_type - find_first_not_of(const _CharT* __str, - size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept - { - return this->find_first_not_of(__str, __pos, - traits_type::length(__str)); - } - - /*constexpr*/ size_type - find_last_not_of(basic_string_view __str, - size_type __pos = npos) const noexcept - { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); } - - /*constexpr*/ size_type - find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept; - - /*constexpr*/ size_type - find_last_not_of(const _CharT* __str, - size_type __pos, size_type __n) const; - - /*constexpr*/ size_type - find_last_not_of(const _CharT* __str, - size_type __pos = npos) const noexcept - { - return this->find_last_not_of(__str, __pos, - traits_type::length(__str)); - } - - private: - - static constexpr int - _S_compare(size_type __n1, size_type __n2) noexcept - { - return difference_type(__n1 - __n2) > std::numeric_limits::max() - ? std::numeric_limits::max() - : difference_type(__n1 - __n2) < std::numeric_limits::min() - ? std::numeric_limits::min() - : static_cast(difference_type(__n1 - __n2)); - } - - size_t _M_len; - const _CharT* _M_str; - }; - - // [string.view.comparison], non-member basic_string_view comparison functions - - namespace __detail - { - // Identity transform to create a non-deduced context, so that only one - // argument participates in template argument deduction and the other - // argument gets implicitly converted to the deduced type. See n3766.html. - template - using __idt = typename std::common_type<_Tp>::type; - } - - template - /*constexpr*/ bool - operator==(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.size() == __y.size() && __x.compare(__y) == 0; } - - template - /*constexpr*/ bool - operator==(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.size() == __y.size() && __x.compare(__y) == 0; } - - template - /*constexpr*/ bool - operator==(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.size() == __y.size() && __x.compare(__y) == 0; } - - template - /*constexpr*/ bool - operator!=(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return !(__x == __y); } - - template - /*constexpr*/ bool - operator!=(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return !(__x == __y); } - - template - /*constexpr*/ bool - operator!=(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return !(__x == __y); } - - template - /*constexpr*/ bool - operator< (basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) < 0; } - - template - /*constexpr*/ bool - operator< (basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) < 0; } - - template - /*constexpr*/ bool - operator< (__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) < 0; } - - template - /*constexpr*/ bool - operator> (basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) > 0; } - - template - /*constexpr*/ bool - operator> (basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) > 0; } - - template - /*constexpr*/ bool - operator> (__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) > 0; } - - template - /*constexpr*/ bool - operator<=(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) <= 0; } - - template - /*constexpr*/ bool - operator<=(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) <= 0; } - - template - /*constexpr*/ bool - operator<=(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) <= 0; } - - template - /*constexpr*/ bool - operator>=(basic_string_view<_CharT, _Traits> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) >= 0; } - - template - /*constexpr*/ bool - operator>=(basic_string_view<_CharT, _Traits> __x, - __detail::__idt> __y) noexcept - { return __x.compare(__y) >= 0; } - - template - /*constexpr*/ bool - operator>=(__detail::__idt> __x, - basic_string_view<_CharT, _Traits> __y) noexcept - { return __x.compare(__y) >= 0; } - - // basic_string_view typedef names - - using string_view = basic_string_view; -} /* namespace gdb */ - -#include "gdb_string_view.tcc" - -#endif // __cplusplus < 201703L - -namespace gdb { - -static inline std::string -to_string(const std::string_view &view) -{ - return { view.data (), view.size () }; -} - -} - -#endif /* COMMON_GDB_STRING_VIEW_H */ diff --git a/gdbsupport/gdb_string_view.tcc b/gdbsupport/gdb_string_view.tcc deleted file mode 100644 index 0798105673b..00000000000 --- a/gdbsupport/gdb_string_view.tcc +++ /dev/null @@ -1,219 +0,0 @@ -// Components for manipulating non-owning sequences of characters -*- C++ -*- - -// Note: This file has been stolen from the gcc repo -// (libstdc++-v3/include/experimental/bits/string_view.tcc) and has local -// modifications. - -// Copyright (C) 2013-2023 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -/** @file experimental/bits/string_view.tcc - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{experimental/string_view} - */ - -// -// N3762 basic_string_view library -// - -#ifndef GDB_STRING_VIEW_TCC -#define GDB_STRING_VIEW_TCC 1 - -namespace gdb -{ - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find(const _CharT* __str, size_type __pos, size_type __n) const noexcept - { - gdb_assert (__str != nullptr || __n == 0); - - if (__n == 0) - return __pos <= this->_M_len ? __pos : npos; - - if (__n <= this->_M_len) - { - for (; __pos <= this->_M_len - __n; ++__pos) - if (traits_type::eq(this->_M_str[__pos], __str[0]) - && traits_type::compare(this->_M_str + __pos + 1, - __str + 1, __n - 1) == 0) - return __pos; - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find(_CharT __c, size_type __pos) const noexcept - { - size_type __ret = npos; - if (__pos < this->_M_len) - { - const size_type __n = this->_M_len - __pos; - const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c); - if (__p) - __ret = __p - this->_M_str; - } - return __ret; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept - { - gdb_assert (__str != nullptr || __n == 0); - - if (__n <= this->_M_len) - { - __pos = std::min(size_type(this->_M_len - __n), __pos); - do - { - if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0) - return __pos; - } - while (__pos-- > 0); - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - rfind(_CharT __c, size_type __pos) const noexcept - { - size_type __size = this->_M_len; - if (__size > 0) - { - if (--__size > __pos) - __size = __pos; - for (++__size; __size-- > 0; ) - if (traits_type::eq(this->_M_str[__size], __c)) - return __size; - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_first_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - for (; __n && __pos < this->_M_len; ++__pos) - { - const _CharT* __p = traits_type::find(__str, __n, - this->_M_str[__pos]); - if (__p) - return __pos; - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_last_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - size_type __size = this->size(); - if (__size && __n) - { - if (--__size > __pos) - __size = __pos; - do - { - if (traits_type::find(__str, __n, this->_M_str[__size])) - return __size; - } - while (__size-- != 0); - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - for (; __pos < this->_M_len; ++__pos) - if (!traits_type::find(__str, __n, this->_M_str[__pos])) - return __pos; - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_first_not_of(_CharT __c, size_type __pos) const noexcept - { - for (; __pos < this->_M_len; ++__pos) - if (!traits_type::eq(this->_M_str[__pos], __c)) - return __pos; - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const - { - gdb_assert (__str != nullptr || __n == 0); - size_type __size = this->_M_len; - if (__size) - { - if (--__size > __pos) - __size = __pos; - do - { - if (!traits_type::find(__str, __n, this->_M_str[__size])) - return __size; - } - while (__size--); - } - return npos; - } - - template - /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type - basic_string_view<_CharT, _Traits>:: - find_last_not_of(_CharT __c, size_type __pos) const noexcept - { - size_type __size = this->_M_len; - if (__size) - { - if (--__size > __pos) - __size = __pos; - do - { - if (!traits_type::eq(this->_M_str[__size], __c)) - return __size; - } - while (__size--); - } - return npos; - } -} // namespace gdb - -#endif // GDB_STRING_VIEW_TCC