1 // { dg-options "-std=gnu++23" }
2 // { dg-do run { target c++23 } }
3 
4 // Copyright (C) 2021 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11 
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3.  If not see
19 // <http://www.gnu.org/licenses/>.
20 
21 // basic_string contains
22 
23 #include <string>
24 #include <testsuite_hooks.h>
25 
26 void
test01()27 test01()
28 {
29     const std::wstring haystack(L"no place for needles");
30 
31     VERIFY(haystack.contains(std::wstring(L"")));
32     VERIFY(haystack.contains(std::wstring(L"no")));
33     VERIFY(haystack.contains(std::wstring(L"needles")));
34     VERIFY(haystack.contains(std::wstring(L" for ")));
35     VERIFY(!haystack.contains(std::wstring(L"places")));
36 
37     VERIFY(haystack.contains(std::wstring_view(L"")));
38     VERIFY(haystack.contains(std::wstring_view(L"no")));
39     VERIFY(haystack.contains(std::wstring_view(L"needles")));
40     VERIFY(haystack.contains(std::wstring_view(L" for ")));
41     VERIFY(!haystack.contains(std::wstring_view(L"places")));
42 
43     VERIFY(!haystack.contains('\0'));
44     VERIFY(haystack.contains('n'));
45     VERIFY(haystack.contains('e'));
46     VERIFY(haystack.contains('s'));
47     VERIFY(!haystack.contains('x'));
48 
49     VERIFY(haystack.contains(L""));
50     VERIFY(haystack.contains(L"no"));
51     VERIFY(haystack.contains(L"needles"));
52     VERIFY(haystack.contains(L" for "));
53     VERIFY(!haystack.contains(L"places"));
54 
55     const std::wstring nothing;
56     VERIFY(nothing.contains(L""));
57     VERIFY(!nothing.contains('\0'));
58 }
59 
60 int
main()61 main()
62 {
63   test01();
64   return 0;
65 }
66