]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/operations/ends_with/char.cc
1 // { dg-do run { target c++20 } }
3 // Copyright (C) 2018-2024 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // basic_string ends_with
22 #include <testsuite_string.h>
23 #include <testsuite_hooks.h>
28 const char cstr_suf
[] = ".jpg";
29 const std::string_view
sv_suf(".jpg");
30 const char cstr_suf2
[] = ".rgb";
31 const std::string_view
sv_suf2(".rgb");
33 const __gnu_test::string
s_test("slugs/slimy.jpg");
35 const auto cstr_in_slugs
= s_test
.ends_with(cstr_suf
);
36 VERIFY( cstr_in_slugs
);
37 const auto sv_in_slugs
= s_test
.ends_with(sv_suf
);
38 VERIFY( sv_in_slugs
);
39 const auto char_g
= s_test
.ends_with('g');
42 const auto cstr_in_worms
= s_test
.ends_with(cstr_suf2
);
43 VERIFY( !cstr_in_worms
);
44 const auto sv_in_worms
= s_test
.ends_with(sv_suf2
);
45 VERIFY( !sv_in_worms
);
46 const auto char_b
= s_test
.ends_with('b');