]>
Commit | Line | Data |
---|---|---|
ca8f2cb1 | 1 | // { dg-options "-std=gnu++17" } |
6458742a | 2 | // { dg-do run { target c++17 } } |
ca8f2cb1 | 3 | |
99dee823 | 4 | // Copyright (C) 2016-2021 Free Software Foundation, Inc. |
ca8f2cb1 VV |
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 | // [string::find] | |
22 | // [string::rfind] | |
23 | // [string::find.first.of] | |
24 | // [string::find.last.of] | |
25 | // [string::find.first.not.of] | |
26 | // [string::find.last.not.of] | |
27 | ||
28 | #include <string> | |
29 | #include <testsuite_hooks.h> | |
30 | ||
31 | void | |
32 | test03() | |
33 | { | |
ca8f2cb1 VV |
34 | std::wstring_view str1(L"bar"); |
35 | std::wstring str2(L"foobar"); | |
36 | ||
37 | auto x = str2.find(str1); | |
38 | VERIFY (x == 3); | |
39 | ||
40 | x = str2.find(str1, 1); | |
41 | VERIFY (x == 3); | |
42 | ||
43 | str2 = L"barbar"; | |
44 | x = str2.rfind(str1); | |
45 | VERIFY (x == 3); | |
46 | ||
47 | x = str2.rfind(str1, 0); | |
48 | VERIFY (x == 0); | |
49 | ||
50 | x = str2.rfind(str1, 3); | |
51 | VERIFY (x == 3); | |
52 | ||
53 | str2 = L"foobarxyz"; | |
54 | str1 = L"zyx"; | |
55 | x = str2.find_first_of(str1); | |
56 | VERIFY (x == 6); | |
57 | ||
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); | |
67 | ||
68 | str2 = L"abcabcabcxxx"; | |
69 | str1 = L"cba"; | |
70 | x = str2.find_first_not_of(str1); | |
71 | VERIFY (x == 9); | |
72 | ||
73 | str2 = L"abcabcabcxxxabcabcxxx"; | |
74 | x = str2.find_first_not_of(str1, 12); | |
75 | VERIFY (x == 18); | |
76 | ||
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); | |
82 | } | |
83 | ||
84 | int main() | |
85 | { | |
86 | test03(); | |
87 | return 0; | |
88 | } |