Merge from the pain train
[official-gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string / find / wchar_t / 3.cc
blobdd27c4380634e46efe290c1d40d5cf3535f0a4dc
1 // 2003-05-04 Paolo Carlini <pcarlini@unitus.it>
3 // Copyright (C) 2003, 2005 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 2, 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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
21 // 21.3.6.5 basic_string find_first_not_of
23 #include <string>
24 #include <testsuite_hooks.h>
26 bool test03(void)
28 bool test __attribute__((unused)) = true;
29 typedef std::wstring::size_type csize_type;
30 csize_type npos = std::wstring::npos;
31 csize_type csz01;
33 const std::wstring str01(L"Bob Rock, per me");
34 const wchar_t str_lit01[] = L"Bob Rock";
35 std::wstring str02(L"ovvero Trivi");
36 std::wstring str03(str_lit01);
37 std::wstring str04;
39 // size_type find_first_not_of(const string&, size_type pos = 0) const;
40 csz01 = str01.find_first_not_of(str01);
41 VERIFY( csz01 == npos );
42 csz01 = str01.find_first_not_of(str02, 0);
43 VERIFY( csz01 == 0 );
44 csz01 = str01.find_first_not_of(str02, 10);
45 VERIFY( csz01 == 10 );
46 csz01 = str01.find_first_not_of(str02, 12);
47 VERIFY( csz01 == 14 );
48 csz01 = str01.find_first_not_of(str03, 0);
49 VERIFY( csz01 == 8 );
50 csz01 = str01.find_first_not_of(str03, 15);
51 VERIFY( csz01 == 15 );
52 csz01 = str01.find_first_not_of(str03, 16);
53 VERIFY( csz01 == npos );
54 csz01 = str01.find_first_not_of(str04, 0);
55 VERIFY( csz01 == 0 );
56 csz01 = str01.find_first_not_of(str04, 12);
57 VERIFY( csz01 == 12 );
58 csz01 = str03.find_first_not_of(str01, 0);
59 VERIFY( csz01 == npos );
60 csz01 = str04.find_first_not_of(str02, 0);
61 VERIFY( csz01 == npos );
63 // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
64 csz01 = str01.find_first_not_of(str_lit01, 0, 0);
65 VERIFY( csz01 == 0 );
66 csz01 = str01.find_first_not_of(str_lit01, 0, 8);
67 VERIFY( csz01 == 8 );
68 csz01 = str01.find_first_not_of(str_lit01, 10, 0);
69 VERIFY( csz01 == 10 );
71 // size_type find_first_not_of(const char* s, size_type pos = 0) const;
72 csz01 = str01.find_first_not_of(str_lit01);
73 VERIFY( csz01 == 8 );
74 csz01 = str02.find_first_not_of(str_lit01, 2);
75 VERIFY( csz01 == 2 );
77 // size_type find_first_not_of(char c, size_type pos = 0) const;
78 csz01 = str01.find_first_not_of(L'B');
79 VERIFY( csz01 == 1 );
80 csz01 = str01.find_first_not_of(L'o', 1);
81 VERIFY( csz01 == 2 );
82 csz01 = str02.find_first_not_of(L'z');
83 VERIFY( csz01 == 0 );
84 csz01 = str04.find_first_not_of(L'S');
85 VERIFY( csz01 == npos );
86 return test;
89 int main()
91 test03();
92 return 0;