]>
Commit | Line | Data |
---|---|---|
f004d6d9 PF |
1 | // { dg-do run { target c++23 } } |
2 | ||
a945c346 | 3 | // Copyright (C) 2021-2024 Free Software Foundation, Inc. |
f004d6d9 PF |
4 | // |
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) | |
9 | // any later version. | |
10 | ||
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. | |
15 | ||
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/>. | |
19 | ||
20 | // basic_string contains | |
21 | ||
22 | #include <string> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | void | |
26 | test01() | |
27 | { | |
28 | const std::string haystack("no place for needles"); | |
29 | ||
30 | VERIFY(haystack.contains(std::string(""))); | |
31 | VERIFY(haystack.contains(std::string("no"))); | |
32 | VERIFY(haystack.contains(std::string("needles"))); | |
33 | VERIFY(haystack.contains(std::string(" for "))); | |
34 | VERIFY(!haystack.contains(std::string("places"))); | |
35 | ||
36 | VERIFY(haystack.contains(std::string_view(""))); | |
37 | VERIFY(haystack.contains(std::string_view("no"))); | |
38 | VERIFY(haystack.contains(std::string_view("needles"))); | |
39 | VERIFY(haystack.contains(std::string_view(" for "))); | |
40 | VERIFY(!haystack.contains(std::string_view("places"))); | |
41 | ||
42 | VERIFY(!haystack.contains('\0')); | |
43 | VERIFY(haystack.contains('n')); | |
44 | VERIFY(haystack.contains('e')); | |
45 | VERIFY(haystack.contains('s')); | |
46 | VERIFY(!haystack.contains('x')); | |
47 | ||
48 | VERIFY(haystack.contains("")); | |
49 | VERIFY(haystack.contains("no")); | |
50 | VERIFY(haystack.contains("needles")); | |
51 | VERIFY(haystack.contains(" for ")); | |
52 | VERIFY(!haystack.contains("places")); | |
53 | ||
54 | const std::string nothing; | |
55 | VERIFY(nothing.contains("")); | |
56 | VERIFY(!nothing.contains('\0')); | |
57 | } | |
58 | ||
59 | int | |
60 | main() | |
61 | { | |
62 | test01(); | |
63 | return 0; | |
64 | } |