1// 2003-05-04 Paolo Carlini <pcarlini@unitus.it> 2 3// Copyright (C) 2003, 2005, 2009 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. 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 17// with this library; see the file COPYING3. If not see 18// <http://www.gnu.org/licenses/>. 19 20// 21.3.6.5 basic_string find_first_not_of 21 22#include <string> 23#include <testsuite_hooks.h> 24 25bool test03(void) 26{ 27 bool test __attribute__((unused)) = true; 28 typedef std::wstring::size_type csize_type; 29 csize_type npos = std::wstring::npos; 30 csize_type csz01; 31 32 const std::wstring str01(L"Bob Rock, per me"); 33 const wchar_t str_lit01[] = L"Bob Rock"; 34 std::wstring str02(L"ovvero Trivi"); 35 std::wstring str03(str_lit01); 36 std::wstring str04; 37 38 // size_type find_first_not_of(const string&, size_type pos = 0) const; 39 csz01 = str01.find_first_not_of(str01); 40 VERIFY( csz01 == npos ); 41 csz01 = str01.find_first_not_of(str02, 0); 42 VERIFY( csz01 == 0 ); 43 csz01 = str01.find_first_not_of(str02, 10); 44 VERIFY( csz01 == 10 ); 45 csz01 = str01.find_first_not_of(str02, 12); 46 VERIFY( csz01 == 14 ); 47 csz01 = str01.find_first_not_of(str03, 0); 48 VERIFY( csz01 == 8 ); 49 csz01 = str01.find_first_not_of(str03, 15); 50 VERIFY( csz01 == 15 ); 51 csz01 = str01.find_first_not_of(str03, 16); 52 VERIFY( csz01 == npos ); 53 csz01 = str01.find_first_not_of(str04, 0); 54 VERIFY( csz01 == 0 ); 55 csz01 = str01.find_first_not_of(str04, 12); 56 VERIFY( csz01 == 12 ); 57 csz01 = str03.find_first_not_of(str01, 0); 58 VERIFY( csz01 == npos ); 59 csz01 = str04.find_first_not_of(str02, 0); 60 VERIFY( csz01 == npos ); 61 62 // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; 63 csz01 = str01.find_first_not_of(str_lit01, 0, 0); 64 VERIFY( csz01 == 0 ); 65 csz01 = str01.find_first_not_of(str_lit01, 0, 8); 66 VERIFY( csz01 == 8 ); 67 csz01 = str01.find_first_not_of(str_lit01, 10, 0); 68 VERIFY( csz01 == 10 ); 69 70 // size_type find_first_not_of(const char* s, size_type pos = 0) const; 71 csz01 = str01.find_first_not_of(str_lit01); 72 VERIFY( csz01 == 8 ); 73 csz01 = str02.find_first_not_of(str_lit01, 2); 74 VERIFY( csz01 == 2 ); 75 76 // size_type find_first_not_of(char c, size_type pos = 0) const; 77 csz01 = str01.find_first_not_of(L'B'); 78 VERIFY( csz01 == 1 ); 79 csz01 = str01.find_first_not_of(L'o', 1); 80 VERIFY( csz01 == 2 ); 81 csz01 = str02.find_first_not_of(L'z'); 82 VERIFY( csz01 == 0 ); 83 csz01 = str04.find_first_not_of(L'S'); 84 VERIFY( csz01 == npos ); 85 return test; 86} 87 88int main() 89{ 90 test03(); 91 return 0; 92} 93