Implement std::string_view and P0254r2,
[official-gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string_view / operations / find / wchar_t / 3.cc
blob82357b807d1f28625d1e4e784cd0039afb5cdfa3
1 // { dg-options "-std=gnu++17" }
3 // Copyright (C) 2013-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 // basic_string_view find_first_not_of
22 #include <string_view>
23 #include <testsuite_hooks.h>
25 bool
26 test03()
28 bool test [[gnu::unused]] = true;
30 typedef std::wstring_view::size_type csize_type;
31 csize_type npos = std::wstring_view::npos;
32 csize_type csz01;
34 const std::wstring_view str01(L"Bob Rock, per me");
35 const wchar_t str_lit01[] = L"Bob Rock";
36 std::wstring_view str02(L"ovvero Trivi");
37 std::wstring_view str03(str_lit01);
38 std::wstring_view str04;
40 // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
41 csz01 = str01.find_first_not_of(str01);
42 VERIFY( csz01 == npos );
43 csz01 = str01.find_first_not_of(str02, 0);
44 VERIFY( csz01 == 0 );
45 csz01 = str01.find_first_not_of(str02, 10);
46 VERIFY( csz01 == 10 );
47 csz01 = str01.find_first_not_of(str02, 12);
48 VERIFY( csz01 == 14 );
49 csz01 = str01.find_first_not_of(str03, 0);
50 VERIFY( csz01 == 8 );
51 csz01 = str01.find_first_not_of(str03, 15);
52 VERIFY( csz01 == 15 );
53 csz01 = str01.find_first_not_of(str03, 16);
54 VERIFY( csz01 == npos );
55 csz01 = str01.find_first_not_of(str04, 0);
56 VERIFY( csz01 == 0 );
57 csz01 = str01.find_first_not_of(str04, 12);
58 VERIFY( csz01 == 12 );
59 csz01 = str03.find_first_not_of(str01, 0);
60 VERIFY( csz01 == npos );
61 csz01 = str04.find_first_not_of(str02, 0);
62 VERIFY( csz01 == npos );
64 // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
65 csz01 = str01.find_first_not_of(str_lit01, 0, 0);
66 VERIFY( csz01 == 0 );
67 csz01 = str01.find_first_not_of(str_lit01, 0, 8);
68 VERIFY( csz01 == 8 );
69 csz01 = str01.find_first_not_of(str_lit01, 10, 0);
70 VERIFY( csz01 == 10 );
72 // size_type find_first_not_of(const char* s, size_type pos = 0) const;
73 csz01 = str01.find_first_not_of(str_lit01);
74 VERIFY( csz01 == 8 );
75 csz01 = str02.find_first_not_of(str_lit01, 2);
76 VERIFY( csz01 == 2 );
78 // size_type find_first_not_of(char c, size_type pos = 0) const;
79 csz01 = str01.find_first_not_of(L'B');
80 VERIFY( csz01 == 1 );
81 csz01 = str01.find_first_not_of(L'o', 1);
82 VERIFY( csz01 == 2 );
83 csz01 = str02.find_first_not_of(L'z');
84 VERIFY( csz01 == 0 );
85 csz01 = str04.find_first_not_of(L'S');
86 VERIFY( csz01 == npos );
88 return test;
91 int
92 main()
94 test03();
96 return 0;