]>
Commit | Line | Data |
---|---|---|
85819f7c PC |
1 | // 2003-05-04 Paolo Carlini <pcarlini@unitus.it> |
2 | ||
83ffe9cd | 3 | // Copyright (C) 2003-2023 Free Software Foundation, Inc. |
85819f7c PC |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
85819f7c PC |
9 | // any later version. |
10 | ||
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. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
85819f7c PC |
19 | |
20 | // 21.3.6.5 basic_string find_first_not_of | |
21 | ||
c66dc023 | 22 | #include <testsuite_string.h> |
85819f7c PC |
23 | #include <testsuite_hooks.h> |
24 | ||
118c8424 | 25 | void test03(void) |
85819f7c | 26 | { |
c66dc023 FD |
27 | typedef __gnu_test::wstring::size_type csize_type; |
28 | csize_type npos = __gnu_test::wstring::npos; | |
85819f7c PC |
29 | csize_type csz01; |
30 | ||
c66dc023 | 31 | const __gnu_test::wstring str01(L"Bob Rock, per me"); |
85819f7c | 32 | const wchar_t str_lit01[] = L"Bob Rock"; |
c66dc023 FD |
33 | __gnu_test::wstring str02(L"ovvero Trivi"); |
34 | __gnu_test::wstring str03(str_lit01); | |
35 | __gnu_test::wstring str04; | |
85819f7c PC |
36 | |
37 | // size_type find_first_not_of(const string&, size_type pos = 0) const; | |
38 | csz01 = str01.find_first_not_of(str01); | |
39 | VERIFY( csz01 == npos ); | |
40 | csz01 = str01.find_first_not_of(str02, 0); | |
41 | VERIFY( csz01 == 0 ); | |
42 | csz01 = str01.find_first_not_of(str02, 10); | |
43 | VERIFY( csz01 == 10 ); | |
44 | csz01 = str01.find_first_not_of(str02, 12); | |
45 | VERIFY( csz01 == 14 ); | |
46 | csz01 = str01.find_first_not_of(str03, 0); | |
47 | VERIFY( csz01 == 8 ); | |
48 | csz01 = str01.find_first_not_of(str03, 15); | |
49 | VERIFY( csz01 == 15 ); | |
50 | csz01 = str01.find_first_not_of(str03, 16); | |
51 | VERIFY( csz01 == npos ); | |
52 | csz01 = str01.find_first_not_of(str04, 0); | |
53 | VERIFY( csz01 == 0 ); | |
54 | csz01 = str01.find_first_not_of(str04, 12); | |
55 | VERIFY( csz01 == 12 ); | |
56 | csz01 = str03.find_first_not_of(str01, 0); | |
57 | VERIFY( csz01 == npos ); | |
58 | csz01 = str04.find_first_not_of(str02, 0); | |
59 | VERIFY( csz01 == npos ); | |
60 | ||
61 | // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; | |
62 | csz01 = str01.find_first_not_of(str_lit01, 0, 0); | |
63 | VERIFY( csz01 == 0 ); | |
b949d64b | 64 | csz01 = str01.find_first_not_of(str_lit01, 0, 8); |
85819f7c PC |
65 | VERIFY( csz01 == 8 ); |
66 | csz01 = str01.find_first_not_of(str_lit01, 10, 0); | |
67 | VERIFY( csz01 == 10 ); | |
68 | ||
69 | // size_type find_first_not_of(const char* s, size_type pos = 0) const; | |
70 | csz01 = str01.find_first_not_of(str_lit01); | |
71 | VERIFY( csz01 == 8 ); | |
72 | csz01 = str02.find_first_not_of(str_lit01, 2); | |
73 | VERIFY( csz01 == 2 ); | |
74 | ||
75 | // size_type find_first_not_of(char c, size_type pos = 0) const; | |
76 | csz01 = str01.find_first_not_of(L'B'); | |
77 | VERIFY( csz01 == 1 ); | |
78 | csz01 = str01.find_first_not_of(L'o', 1); | |
79 | VERIFY( csz01 == 2 ); | |
80 | csz01 = str02.find_first_not_of(L'z'); | |
81 | VERIFY( csz01 == 0 ); | |
82 | csz01 = str04.find_first_not_of(L'S'); | |
83 | VERIFY( csz01 == npos ); | |
85819f7c PC |
84 | } |
85 | ||
86 | int main() | |
87 | { | |
88 | test03(); | |
89 | return 0; | |
90 | } |