Implement std::string_view and P0254r2,
[official-gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string / operations / find / wchar_t / 5.cc
blob701cc4cca1bca94db3aee351e0ebbee0d4b7d357
1 // { dg-options "-std=gnu++17" }
3 // Copyright (C) 2016 Free Software Foundation, Inc.
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.
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 // [string::find]
21 // [string::rfind]
22 // [string::find.first.of]
23 // [string::find.last.of]
24 // [string::find.first.not.of]
25 // [string::find.last.not.of]
27 #include <string>
28 #include <testsuite_hooks.h>
30 void
31 test03()
33 bool test __attribute__((unused)) = true;
34 std::wstring_view str1(L"bar");
35 std::wstring str2(L"foobar");
37 auto x = str2.find(str1);
38 VERIFY (x == 3);
40 x = str2.find(str1, 1);
41 VERIFY (x == 3);
43 str2 = L"barbar";
44 x = str2.rfind(str1);
45 VERIFY (x == 3);
47 x = str2.rfind(str1, 0);
48 VERIFY (x == 0);
50 x = str2.rfind(str1, 3);
51 VERIFY (x == 3);
53 str2 = L"foobarxyz";
54 str1 = L"zyx";
55 x = str2.find_first_of(str1);
56 VERIFY (x == 6);
58 str2 = L"foobarxyzfooxyz";
59 x = str2.find_first_of(str1);
60 VERIFY (x == 6);
61 x = str2.find_first_of(str1, 9);
62 VERIFY (x == 12);
63 x = str2.find_last_of(str1);
64 VERIFY (x == 14);
65 x = str2.find_last_of(str1, 10);
66 VERIFY (x == 8);
68 str2 = L"abcabcabcxxx";
69 str1 = L"cba";
70 x = str2.find_first_not_of(str1);
71 VERIFY (x == 9);
73 str2 = L"abcabcabcxxxabcabcxxx";
74 x = str2.find_first_not_of(str1, 12);
75 VERIFY (x == 18);
77 str1 = L"x";
78 x = str2.find_last_not_of(str1);
79 VERIFY (x == 17);
80 x = str2.find_last_not_of(str1, 11);
81 VERIFY (x == 8);
84 int main()
86 test03();
87 return 0;