From: Paolo Carlini Date: Fri, 28 Jun 2013 16:01:08 +0000 (+0000) Subject: *: Move inside testsuite/21_strings/basic_string/operations/data/. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d9800e39ad29174231a13405f11e82dd9d430d2;p=gcc.git *: Move inside testsuite/21_strings/basic_string/operations/data/. 2013-06-27 Paolo Carlini * testsuite/21_strings/basic_string/operations/*: Move inside testsuite/21_strings/basic_string/operations/data/. * testsuite/21_strings/basic_string/compare/*: Move inside testsuite/21_strings/basic_string/operations/. * testsuite/21_strings/basic_string/find/*: Likewise. * testsuite/21_strings/basic_string/rfind/*: Likewise. * testsuite/21_strings/basic_string/substr/*: Likewise. From-SVN: r200537 --- diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/1.cc deleted file mode 100644 index 5561630014a..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/1.cc +++ /dev/null @@ -1,133 +0,0 @@ -// 980930 bkoz work with libstdc++v3 - -// Copyright (C) 1998-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.8 basic_string::compare -// int compare(const basic_string& str) const; -// int compare(size_type pos1, size_type n1, const basic_string& str) const; -// int compare(size_type pos1, size_type n1, const basic_string& str, -// size_type pos2, size_type n2) const; -// int compare(const charT* s) const; -// int compare(size_type pos1, size_type n1, -// const charT* s, size_type n2 = npos) const; - -// NB compare should be thought of as a lexographical compare, ie how -// things would be sorted in a dictionary. - -#include -#include -#include - -enum want_value {lt=0, z=1, gt=2}; - -int -test_value(int result, want_value expected); - -int -test_value(int result, want_value expected) -{ - bool test __attribute__((unused)) = true; - bool pass = false; - - switch (expected) { - case lt: - if (result < 0) - pass = true; - break; - case z: - if (!result) - pass = true; - break; - case gt: - if (result > 0) - pass = true; - break; - default: - pass = false; //should not get here - } - VERIFY(pass); - return 0; -} - - -int -test01() -{ - using namespace std; - - string str_0("costa rica"); - string str_1("costa marbella"); - string str_2; - - //sanity check - test_value(strcmp("costa marbella", "costa rica"), lt); - test_value(strcmp("costa rica", "costa rica"), z); - test_value(strcmp(str_1.data(), str_0.data()), lt); - test_value(strcmp(str_0.data(), str_1.data()), gt); - test_value(strncmp(str_1.data(), str_0.data(), 6), z); - test_value(strncmp(str_1.data(), str_0.data(), 14), lt); - test_value(memcmp(str_1.data(), str_0.data(), 6), z); - test_value(memcmp(str_1.data(), str_0.data(), 14), lt); - test_value(memcmp("costa marbella", "costa rica", 14), lt); - - // int compare(const basic_string& str) const; - test_value(str_0.compare(str_1), gt); //because r>m - test_value(str_1.compare(str_0), lt); //because m - -// Copyright (C) 2004-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.8 basic_string::compare [lib.string::compare] - -#include -#include - -// libstdc++/13650 -void test01() -{ - using namespace std; - bool test __attribute__((unused)) = true; - - const char lit_01[] = { 'w', 'e', '\0', 'r', 'd' }; - const char lit_02[] = { 'w', 'e', 'i', '\0', 'd' }; - - const char lit_ref_a[] = { 'w', 'e', '\0', 'q', 'd' }; - const string str_a(lit_ref_a, 5); - VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); - - const char lit_ref_b[] = { 'w', 'e', 'i' }; - const string str_b(lit_ref_b, 3); - VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/1.cc deleted file mode 100644 index ca5962de3c3..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/1.cc +++ /dev/null @@ -1,133 +0,0 @@ -// 980930 bkoz work with libstdc++v3 - -// Copyright (C) 1998-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.8 basic_string::compare -// int compare(const basic_string& str) const; -// int compare(size_type pos1, size_type n1, const basic_string& str) const; -// int compare(size_type pos1, size_type n1, const basic_string& str, -// size_type pos2, size_type n2) const; -// int compare(const charT* s) const; -// int compare(size_type pos1, size_type n1, -// const charT* s, size_type n2 = npos) const; - -// NB compare should be thought of as a lexographical compare, ie how -// things would be sorted in a dictionary. - -#include -#include - -enum want_value {lt=0, z=1, gt=2}; - -int -test_value(int result, want_value expected); - -int -test_value(int result, want_value expected) -{ - bool test __attribute__((unused)) = true; - bool pass = false; - - switch (expected) { - case lt: - if (result < 0) - pass = true; - break; - case z: - if (!result) - pass = true; - break; - case gt: - if (result > 0) - pass = true; - break; - default: - pass = false; //should not get here - } - - VERIFY(pass); - return 0; -} - - -int -test01() -{ - using namespace std; - - wstring str_0(L"costa rica"); - wstring str_1(L"costa marbella"); - wstring str_2; - - //sanity check - test_value(wcscmp(L"costa marbella", L"costa rica"), lt); - test_value(wcscmp(L"costa rica", L"costa rica"), z); - test_value(wcscmp(str_1.data(), str_0.data()), lt); - test_value(wcscmp(str_0.data(), str_1.data()), gt); - test_value(wcsncmp(str_1.data(), str_0.data(), 6), z); - test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt); - test_value(wmemcmp(str_1.data(), str_0.data(), 6), z); - test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt); - test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt); - - // int compare(const basic_string& str) const; - test_value(str_0.compare(str_1), gt); //because r>m - test_value(str_1.compare(str_0), lt); //because m - -// Copyright (C) 2004-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.8 basic_string::compare [lib.string::compare] - -#include -#include - -// libstdc++/13650 -void test01() -{ - using namespace std; - bool test __attribute__((unused)) = true; - - const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' }; - const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' }; - - const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' }; - const wstring str_a(lit_ref_a, 5); - VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); - - const wchar_t lit_ref_b[] = { L'w', L'e', L'i' }; - const wstring str_b(lit_ref_b, 3); - VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/1.cc deleted file mode 100644 index 0c09992d259..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/1.cc +++ /dev/null @@ -1,93 +0,0 @@ -// 1999-06-09 bkoz - -// Copyright (C) 1994-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.1 basic_string find - -#include -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - typedef std::string::const_reference cref; - typedef std::string::reference ref; - csize_type npos = std::string::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const std::string str01("mavericks, santa cruz"); - std::string str02(str_lit01); - std::string str03("s, s"); - std::string str04; - - // size_type find(const string&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string consists of no characters - // therefore it should be found at every point in a string, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const char* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const char* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(char c, size_type pos = 0) const; - csz01 = str01.find('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find('/'); - VERIFY( csz01 == npos ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/2.cc deleted file mode 100644 index 5e8b35a3d49..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/2.cc +++ /dev/null @@ -1,92 +0,0 @@ -// 1999-06-09 bkoz - -// Copyright (C) 1994-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.3 basic_string find_first_of - -#include -#include - -bool test02(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - csize_type npos = std::string::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const std::string str01("mavericks, santa cruz"); - std::string str02(str_lit01); - std::string str03("s, s"); - std::string str04; - - // size_type find_first_of(const string&, size_type pos = 0) const; - std::string str05("xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string consists of no characters - // therefore it should be found at every point in a string, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_of('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - return test; -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/3.cc deleted file mode 100644 index 4dec069c128..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/3.cc +++ /dev/null @@ -1,92 +0,0 @@ -// 2003-05-04 Paolo Carlini - -// Copyright (C) 2003-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.5 basic_string find_first_not_of - -#include -#include - -bool test03(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - csize_type npos = std::string::npos; - csize_type csz01; - - const std::string str01("Bob Rock, per me"); - const char str_lit01[] = "Bob Rock"; - std::string str02("ovvero Trivi"); - std::string str03(str_lit01); - std::string str04; - - // size_type find_first_not_of(const string&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of('B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of('o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of('z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of('S'); - VERIFY( csz01 == npos ); - return test; -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc deleted file mode 100644 index d593f9d5338..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc +++ /dev/null @@ -1,42 +0,0 @@ -// 2007-03-30 Paolo Carlini - -// Copyright (C) 2007-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.1 basic_string find - -#include -#include - -// libstdc++/31401 -void test01() -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - csize_type npos = std::string::npos; - - std::string use = "anu"; - csize_type pos1 = use.find("a", npos); - - VERIFY( pos1 == npos ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/1.cc deleted file mode 100644 index 2b488a3e587..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/1.cc +++ /dev/null @@ -1,93 +0,0 @@ -// 1999-06-09 bkoz - -// Copyright (C) 1994-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.1 basic_string find - -#include -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - typedef std::wstring::const_reference cref; - typedef std::wstring::reference ref; - csize_type npos = std::wstring::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring str01(L"mavericks, santa cruz"); - std::wstring str02(str_lit01); - std::wstring str03(L"s, s"); - std::wstring str04; - - // size_type find(const wstring&, size_type pos = 0) const; - csz01 = str01.find(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str01, 4); - VERIFY( csz01 == npos ); - csz01 = str01.find(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str02, 3); - VERIFY( csz01 == npos ); - csz01 = str01.find(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find(str03, 12); - VERIFY( csz01 == npos ); - - // An empty string consists of no characters - // therefore it should be found at every point in a string, - // except beyond the end - csz01 = str01.find(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.find(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.find(str04, str01.size()+1); - VERIFY( csz01 == npos ); - - // size_type find(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type find(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find(str_lit01, 3); - VERIFY( csz01 == npos ); - - // size_type find(wchar_t c, size_type pos = 0) const; - csz01 = str01.find(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.find(L'/'); - VERIFY( csz01 == npos ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/2.cc deleted file mode 100644 index 3ada8ba3457..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/2.cc +++ /dev/null @@ -1,92 +0,0 @@ -// 1999-06-09 bkoz - -// Copyright (C) 1994-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.3 basic_string find_first_of - -#include -#include - -bool test02(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - csize_type npos = std::wstring::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring str01(L"mavericks, santa cruz"); - std::wstring str02(str_lit01); - std::wstring str03(L"s, s"); - std::wstring str04; - - // size_type find_first_of(const wstring&, size_type pos = 0) const; - std::wstring str05(L"xena rulez"); - csz01 = str01.find_first_of(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str01, 4); - VERIFY( csz01 == 4 ); - csz01 = str01.find_first_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str02, 3); - VERIFY( csz01 == 3 ); - csz01 = str01.find_first_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 3); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_of(str03, 12); - VERIFY( csz01 == 16 ); - csz01 = str01.find_first_of(str05, 0); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_of(str05, 4); - VERIFY( csz01 == 4 ); - - // An empty string consists of no characters - // therefore it should be found at every point in a string, - // except beyond the end - // However, str1.find_first_of(str2,pos) finds the first character in - // str1 (starting at pos) that exists in str2, which is none for empty str2 - csz01 = str01.find_first_of(str04, 0); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_of(str04, 5); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.find_first_of(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_of(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.find_first_of(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_of(str_lit01, 3); - VERIFY( csz01 == 3 ); - - // size_type find_first_of(wchar_t c, size_type pos = 0) const; - csz01 = str01.find_first_of(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - return test; -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/3.cc deleted file mode 100644 index 299c354aad8..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/3.cc +++ /dev/null @@ -1,92 +0,0 @@ -// 2003-05-04 Paolo Carlini - -// Copyright (C) 2003-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.5 basic_string find_first_not_of - -#include -#include - -bool test03(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - csize_type npos = std::wstring::npos; - csize_type csz01; - - const std::wstring str01(L"Bob Rock, per me"); - const wchar_t str_lit01[] = L"Bob Rock"; - std::wstring str02(L"ovvero Trivi"); - std::wstring str03(str_lit01); - std::wstring str04; - - // size_type find_first_not_of(const string&, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str01); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str02, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str02, 10); - VERIFY( csz01 == 10 ); - csz01 = str01.find_first_not_of(str02, 12); - VERIFY( csz01 == 14 ); - csz01 = str01.find_first_not_of(str03, 0); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str03, 15); - VERIFY( csz01 == 15 ); - csz01 = str01.find_first_not_of(str03, 16); - VERIFY( csz01 == npos ); - csz01 = str01.find_first_not_of(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str04, 12); - VERIFY( csz01 == 12 ); - csz01 = str03.find_first_not_of(str01, 0); - VERIFY( csz01 == npos ); - csz01 = str04.find_first_not_of(str02, 0); - VERIFY( csz01 == npos ); - - // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; - csz01 = str01.find_first_not_of(str_lit01, 0, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.find_first_not_of(str_lit01, 0, 8); - VERIFY( csz01 == 8 ); - csz01 = str01.find_first_not_of(str_lit01, 10, 0); - VERIFY( csz01 == 10 ); - - // size_type find_first_not_of(const char* s, size_type pos = 0) const; - csz01 = str01.find_first_not_of(str_lit01); - VERIFY( csz01 == 8 ); - csz01 = str02.find_first_not_of(str_lit01, 2); - VERIFY( csz01 == 2 ); - - // size_type find_first_not_of(char c, size_type pos = 0) const; - csz01 = str01.find_first_not_of(L'B'); - VERIFY( csz01 == 1 ); - csz01 = str01.find_first_not_of(L'o', 1); - VERIFY( csz01 == 2 ); - csz01 = str02.find_first_not_of(L'z'); - VERIFY( csz01 == 0 ); - csz01 = str04.find_first_not_of(L'S'); - VERIFY( csz01 == npos ); - return test; -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc deleted file mode 100644 index 1357eb972d6..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc +++ /dev/null @@ -1,42 +0,0 @@ -// 2007-03-30 Paolo Carlini - -// Copyright (C) 2007-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.1 basic_string find - -#include -#include - -// libstdc++/31401 -void test01() -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - csize_type npos = std::wstring::npos; - - std::wstring use = L"anu"; - csize_type pos1 = use.find(L"a", npos); - - VERIFY( pos1 == npos ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/char/1.cc deleted file mode 100644 index 6fd3d9b62cd..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/char/1.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2004-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6 string operations - -#include -#include - -int test01(void) -{ - bool test __attribute__((unused)) = true; - - std::string empty; - - // data() for size == 0 is non-NULL. - VERIFY( empty.size() == 0 ); - const std::string::value_type* p = empty.data(); - VERIFY( p ); - - return 0; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/1.cc new file mode 100644 index 00000000000..5561630014a --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/1.cc @@ -0,0 +1,133 @@ +// 980930 bkoz work with libstdc++v3 + +// Copyright (C) 1998-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.8 basic_string::compare +// int compare(const basic_string& str) const; +// int compare(size_type pos1, size_type n1, const basic_string& str) const; +// int compare(size_type pos1, size_type n1, const basic_string& str, +// size_type pos2, size_type n2) const; +// int compare(const charT* s) const; +// int compare(size_type pos1, size_type n1, +// const charT* s, size_type n2 = npos) const; + +// NB compare should be thought of as a lexographical compare, ie how +// things would be sorted in a dictionary. + +#include +#include +#include + +enum want_value {lt=0, z=1, gt=2}; + +int +test_value(int result, want_value expected); + +int +test_value(int result, want_value expected) +{ + bool test __attribute__((unused)) = true; + bool pass = false; + + switch (expected) { + case lt: + if (result < 0) + pass = true; + break; + case z: + if (!result) + pass = true; + break; + case gt: + if (result > 0) + pass = true; + break; + default: + pass = false; //should not get here + } + VERIFY(pass); + return 0; +} + + +int +test01() +{ + using namespace std; + + string str_0("costa rica"); + string str_1("costa marbella"); + string str_2; + + //sanity check + test_value(strcmp("costa marbella", "costa rica"), lt); + test_value(strcmp("costa rica", "costa rica"), z); + test_value(strcmp(str_1.data(), str_0.data()), lt); + test_value(strcmp(str_0.data(), str_1.data()), gt); + test_value(strncmp(str_1.data(), str_0.data(), 6), z); + test_value(strncmp(str_1.data(), str_0.data(), 14), lt); + test_value(memcmp(str_1.data(), str_0.data(), 6), z); + test_value(memcmp(str_1.data(), str_0.data(), 14), lt); + test_value(memcmp("costa marbella", "costa rica", 14), lt); + + // int compare(const basic_string& str) const; + test_value(str_0.compare(str_1), gt); //because r>m + test_value(str_1.compare(str_0), lt); //because m + +// Copyright (C) 2004-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.8 basic_string::compare [lib.string::compare] + +#include +#include + +// libstdc++/13650 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const char lit_01[] = { 'w', 'e', '\0', 'r', 'd' }; + const char lit_02[] = { 'w', 'e', 'i', '\0', 'd' }; + + const char lit_ref_a[] = { 'w', 'e', '\0', 'q', 'd' }; + const string str_a(lit_ref_a, 5); + VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); + + const char lit_ref_b[] = { 'w', 'e', 'i' }; + const string str_b(lit_ref_b, 3); + VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc new file mode 100644 index 00000000000..ca5962de3c3 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc @@ -0,0 +1,133 @@ +// 980930 bkoz work with libstdc++v3 + +// Copyright (C) 1998-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.8 basic_string::compare +// int compare(const basic_string& str) const; +// int compare(size_type pos1, size_type n1, const basic_string& str) const; +// int compare(size_type pos1, size_type n1, const basic_string& str, +// size_type pos2, size_type n2) const; +// int compare(const charT* s) const; +// int compare(size_type pos1, size_type n1, +// const charT* s, size_type n2 = npos) const; + +// NB compare should be thought of as a lexographical compare, ie how +// things would be sorted in a dictionary. + +#include +#include + +enum want_value {lt=0, z=1, gt=2}; + +int +test_value(int result, want_value expected); + +int +test_value(int result, want_value expected) +{ + bool test __attribute__((unused)) = true; + bool pass = false; + + switch (expected) { + case lt: + if (result < 0) + pass = true; + break; + case z: + if (!result) + pass = true; + break; + case gt: + if (result > 0) + pass = true; + break; + default: + pass = false; //should not get here + } + + VERIFY(pass); + return 0; +} + + +int +test01() +{ + using namespace std; + + wstring str_0(L"costa rica"); + wstring str_1(L"costa marbella"); + wstring str_2; + + //sanity check + test_value(wcscmp(L"costa marbella", L"costa rica"), lt); + test_value(wcscmp(L"costa rica", L"costa rica"), z); + test_value(wcscmp(str_1.data(), str_0.data()), lt); + test_value(wcscmp(str_0.data(), str_1.data()), gt); + test_value(wcsncmp(str_1.data(), str_0.data(), 6), z); + test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt); + test_value(wmemcmp(str_1.data(), str_0.data(), 6), z); + test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt); + test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt); + + // int compare(const basic_string& str) const; + test_value(str_0.compare(str_1), gt); //because r>m + test_value(str_1.compare(str_0), lt); //because m + +// Copyright (C) 2004-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.8 basic_string::compare [lib.string::compare] + +#include +#include + +// libstdc++/13650 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' }; + const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' }; + + const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' }; + const wstring str_a(lit_ref_a, 5); + VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 ); + + const wchar_t lit_ref_b[] = { L'w', L'e', L'i' }; + const wstring str_b(lit_ref_b, 3); + VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/data/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/data/char/1.cc new file mode 100644 index 00000000000..6fd3d9b62cd --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/data/char/1.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2004-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6 string operations + +#include +#include + +int test01(void) +{ + bool test __attribute__((unused)) = true; + + std::string empty; + + // data() for size == 0 is non-NULL. + VERIFY( empty.size() == 0 ); + const std::string::value_type* p = empty.data(); + VERIFY( p ); + + return 0; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/data/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/data/wchar_t/1.cc new file mode 100644 index 00000000000..97b5d4afcec --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/data/wchar_t/1.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2004-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6 string operations + +#include +#include + +int test01(void) +{ + bool test __attribute__((unused)) = true; + + std::wstring empty; + + // data() for size == 0 is non-NULL. + VERIFY( empty.size() == 0 ); + const std::wstring::value_type* p = empty.data(); + VERIFY( p ); + + return 0; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/1.cc new file mode 100644 index 00000000000..0c09992d259 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/1.cc @@ -0,0 +1,93 @@ +// 1999-06-09 bkoz + +// Copyright (C) 1994-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.1 basic_string find + +#include +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + typedef std::string::const_reference cref; + typedef std::string::reference ref; + csize_type npos = std::string::npos; + csize_type csz01, csz02; + + const char str_lit01[] = "mave"; + const std::string str01("mavericks, santa cruz"); + std::string str02(str_lit01); + std::string str03("s, s"); + std::string str04; + + // size_type find(const string&, size_type pos = 0) const; + csz01 = str01.find(str01); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str01, 4); + VERIFY( csz01 == npos ); + csz01 = str01.find(str02, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str02, 3); + VERIFY( csz01 == npos ); + csz01 = str01.find(str03, 0); + VERIFY( csz01 == 8 ); + csz01 = str01.find(str03, 3); + VERIFY( csz01 == 8 ); + csz01 = str01.find(str03, 12); + VERIFY( csz01 == npos ); + + // An empty string consists of no characters + // therefore it should be found at every point in a string, + // except beyond the end + csz01 = str01.find(str04, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str04, 5); + VERIFY( csz01 == 5 ); + csz01 = str01.find(str04, str01.size()); + VERIFY( csz01 == str01.size() ); + csz01 = str01.find(str04, str01.size()+1); + VERIFY( csz01 == npos ); + + // size_type find(const char* s, size_type pos, size_type n) const; + csz01 = str01.find(str_lit01, 0, 3); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str_lit01, 3, 0); + VERIFY( csz01 == 3 ); + + // size_type find(const char* s, size_type pos = 0) const; + csz01 = str01.find(str_lit01); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str_lit01, 3); + VERIFY( csz01 == npos ); + + // size_type find(char c, size_type pos = 0) const; + csz01 = str01.find('z'); + csz02 = str01.size() - 1; + VERIFY( csz01 == csz02 ); + csz01 = str01.find('/'); + VERIFY( csz01 == npos ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/2.cc new file mode 100644 index 00000000000..5e8b35a3d49 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/2.cc @@ -0,0 +1,92 @@ +// 1999-06-09 bkoz + +// Copyright (C) 1994-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.3 basic_string find_first_of + +#include +#include + +bool test02(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + csize_type npos = std::string::npos; + csize_type csz01, csz02; + + const char str_lit01[] = "mave"; + const std::string str01("mavericks, santa cruz"); + std::string str02(str_lit01); + std::string str03("s, s"); + std::string str04; + + // size_type find_first_of(const string&, size_type pos = 0) const; + std::string str05("xena rulez"); + csz01 = str01.find_first_of(str01); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str01, 4); + VERIFY( csz01 == 4 ); + csz01 = str01.find_first_of(str02, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str02, 3); + VERIFY( csz01 == 3 ); + csz01 = str01.find_first_of(str03, 0); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_of(str03, 3); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_of(str03, 12); + VERIFY( csz01 == 16 ); + csz01 = str01.find_first_of(str05, 0); + VERIFY( csz01 == 1 ); + csz01 = str01.find_first_of(str05, 4); + VERIFY( csz01 == 4 ); + + // An empty string consists of no characters + // therefore it should be found at every point in a string, + // except beyond the end + // However, str1.find_first_of(str2,pos) finds the first character in + // str1 (starting at pos) that exists in str2, which is none for empty str2 + csz01 = str01.find_first_of(str04, 0); + VERIFY( csz01 == npos ); + csz01 = str01.find_first_of(str04, 5); + VERIFY( csz01 == npos ); + + // size_type find_first_of(const char* s, size_type pos, size_type n) const; + csz01 = str01.find_first_of(str_lit01, 0, 3); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str_lit01, 3, 0); + VERIFY( csz01 == npos ); + + // size_type find_first_of(const char* s, size_type pos = 0) const; + csz01 = str01.find_first_of(str_lit01); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str_lit01, 3); + VERIFY( csz01 == 3 ); + + // size_type find_first_of(char c, size_type pos = 0) const; + csz01 = str01.find_first_of('z'); + csz02 = str01.size() - 1; + VERIFY( csz01 == csz02 ); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/3.cc new file mode 100644 index 00000000000..4dec069c128 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/3.cc @@ -0,0 +1,92 @@ +// 2003-05-04 Paolo Carlini + +// Copyright (C) 2003-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.5 basic_string find_first_not_of + +#include +#include + +bool test03(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + csize_type npos = std::string::npos; + csize_type csz01; + + const std::string str01("Bob Rock, per me"); + const char str_lit01[] = "Bob Rock"; + std::string str02("ovvero Trivi"); + std::string str03(str_lit01); + std::string str04; + + // size_type find_first_not_of(const string&, size_type pos = 0) const; + csz01 = str01.find_first_not_of(str01); + VERIFY( csz01 == npos ); + csz01 = str01.find_first_not_of(str02, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_not_of(str02, 10); + VERIFY( csz01 == 10 ); + csz01 = str01.find_first_not_of(str02, 12); + VERIFY( csz01 == 14 ); + csz01 = str01.find_first_not_of(str03, 0); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_not_of(str03, 15); + VERIFY( csz01 == 15 ); + csz01 = str01.find_first_not_of(str03, 16); + VERIFY( csz01 == npos ); + csz01 = str01.find_first_not_of(str04, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_not_of(str04, 12); + VERIFY( csz01 == 12 ); + csz01 = str03.find_first_not_of(str01, 0); + VERIFY( csz01 == npos ); + csz01 = str04.find_first_not_of(str02, 0); + VERIFY( csz01 == npos ); + + // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; + csz01 = str01.find_first_not_of(str_lit01, 0, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_not_of(str_lit01, 0, 8); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_not_of(str_lit01, 10, 0); + VERIFY( csz01 == 10 ); + + // size_type find_first_not_of(const char* s, size_type pos = 0) const; + csz01 = str01.find_first_not_of(str_lit01); + VERIFY( csz01 == 8 ); + csz01 = str02.find_first_not_of(str_lit01, 2); + VERIFY( csz01 == 2 ); + + // size_type find_first_not_of(char c, size_type pos = 0) const; + csz01 = str01.find_first_not_of('B'); + VERIFY( csz01 == 1 ); + csz01 = str01.find_first_not_of('o', 1); + VERIFY( csz01 == 2 ); + csz01 = str02.find_first_not_of('z'); + VERIFY( csz01 == 0 ); + csz01 = str04.find_first_not_of('S'); + VERIFY( csz01 == npos ); + return test; +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/4.cc new file mode 100644 index 00000000000..d593f9d5338 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/4.cc @@ -0,0 +1,42 @@ +// 2007-03-30 Paolo Carlini + +// Copyright (C) 2007-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.1 basic_string find + +#include +#include + +// libstdc++/31401 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + csize_type npos = std::string::npos; + + std::string use = "anu"; + csize_type pos1 = use.find("a", npos); + + VERIFY( pos1 == npos ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc new file mode 100644 index 00000000000..2b488a3e587 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc @@ -0,0 +1,93 @@ +// 1999-06-09 bkoz + +// Copyright (C) 1994-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.1 basic_string find + +#include +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + typedef std::wstring::const_reference cref; + typedef std::wstring::reference ref; + csize_type npos = std::wstring::npos; + csize_type csz01, csz02; + + const wchar_t str_lit01[] = L"mave"; + const std::wstring str01(L"mavericks, santa cruz"); + std::wstring str02(str_lit01); + std::wstring str03(L"s, s"); + std::wstring str04; + + // size_type find(const wstring&, size_type pos = 0) const; + csz01 = str01.find(str01); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str01, 4); + VERIFY( csz01 == npos ); + csz01 = str01.find(str02, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str02, 3); + VERIFY( csz01 == npos ); + csz01 = str01.find(str03, 0); + VERIFY( csz01 == 8 ); + csz01 = str01.find(str03, 3); + VERIFY( csz01 == 8 ); + csz01 = str01.find(str03, 12); + VERIFY( csz01 == npos ); + + // An empty string consists of no characters + // therefore it should be found at every point in a string, + // except beyond the end + csz01 = str01.find(str04, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str04, 5); + VERIFY( csz01 == 5 ); + csz01 = str01.find(str04, str01.size()); + VERIFY( csz01 == str01.size() ); + csz01 = str01.find(str04, str01.size()+1); + VERIFY( csz01 == npos ); + + // size_type find(const wchar_t* s, size_type pos, size_type n) const; + csz01 = str01.find(str_lit01, 0, 3); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str_lit01, 3, 0); + VERIFY( csz01 == 3 ); + + // size_type find(const wchar_t* s, size_type pos = 0) const; + csz01 = str01.find(str_lit01); + VERIFY( csz01 == 0 ); + csz01 = str01.find(str_lit01, 3); + VERIFY( csz01 == npos ); + + // size_type find(wchar_t c, size_type pos = 0) const; + csz01 = str01.find(L'z'); + csz02 = str01.size() - 1; + VERIFY( csz01 == csz02 ); + csz01 = str01.find(L'/'); + VERIFY( csz01 == npos ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc new file mode 100644 index 00000000000..3ada8ba3457 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc @@ -0,0 +1,92 @@ +// 1999-06-09 bkoz + +// Copyright (C) 1994-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.3 basic_string find_first_of + +#include +#include + +bool test02(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + csize_type npos = std::wstring::npos; + csize_type csz01, csz02; + + const wchar_t str_lit01[] = L"mave"; + const std::wstring str01(L"mavericks, santa cruz"); + std::wstring str02(str_lit01); + std::wstring str03(L"s, s"); + std::wstring str04; + + // size_type find_first_of(const wstring&, size_type pos = 0) const; + std::wstring str05(L"xena rulez"); + csz01 = str01.find_first_of(str01); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str01, 4); + VERIFY( csz01 == 4 ); + csz01 = str01.find_first_of(str02, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str02, 3); + VERIFY( csz01 == 3 ); + csz01 = str01.find_first_of(str03, 0); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_of(str03, 3); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_of(str03, 12); + VERIFY( csz01 == 16 ); + csz01 = str01.find_first_of(str05, 0); + VERIFY( csz01 == 1 ); + csz01 = str01.find_first_of(str05, 4); + VERIFY( csz01 == 4 ); + + // An empty string consists of no characters + // therefore it should be found at every point in a string, + // except beyond the end + // However, str1.find_first_of(str2,pos) finds the first character in + // str1 (starting at pos) that exists in str2, which is none for empty str2 + csz01 = str01.find_first_of(str04, 0); + VERIFY( csz01 == npos ); + csz01 = str01.find_first_of(str04, 5); + VERIFY( csz01 == npos ); + + // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const; + csz01 = str01.find_first_of(str_lit01, 0, 3); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str_lit01, 3, 0); + VERIFY( csz01 == npos ); + + // size_type find_first_of(const wchar_t* s, size_type pos = 0) const; + csz01 = str01.find_first_of(str_lit01); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_of(str_lit01, 3); + VERIFY( csz01 == 3 ); + + // size_type find_first_of(wchar_t c, size_type pos = 0) const; + csz01 = str01.find_first_of(L'z'); + csz02 = str01.size() - 1; + VERIFY( csz01 == csz02 ); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc new file mode 100644 index 00000000000..299c354aad8 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc @@ -0,0 +1,92 @@ +// 2003-05-04 Paolo Carlini + +// Copyright (C) 2003-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.5 basic_string find_first_not_of + +#include +#include + +bool test03(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + csize_type npos = std::wstring::npos; + csize_type csz01; + + const std::wstring str01(L"Bob Rock, per me"); + const wchar_t str_lit01[] = L"Bob Rock"; + std::wstring str02(L"ovvero Trivi"); + std::wstring str03(str_lit01); + std::wstring str04; + + // size_type find_first_not_of(const string&, size_type pos = 0) const; + csz01 = str01.find_first_not_of(str01); + VERIFY( csz01 == npos ); + csz01 = str01.find_first_not_of(str02, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_not_of(str02, 10); + VERIFY( csz01 == 10 ); + csz01 = str01.find_first_not_of(str02, 12); + VERIFY( csz01 == 14 ); + csz01 = str01.find_first_not_of(str03, 0); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_not_of(str03, 15); + VERIFY( csz01 == 15 ); + csz01 = str01.find_first_not_of(str03, 16); + VERIFY( csz01 == npos ); + csz01 = str01.find_first_not_of(str04, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_not_of(str04, 12); + VERIFY( csz01 == 12 ); + csz01 = str03.find_first_not_of(str01, 0); + VERIFY( csz01 == npos ); + csz01 = str04.find_first_not_of(str02, 0); + VERIFY( csz01 == npos ); + + // size_type find_first_not_of(const char* s, size_type pos, size_type n) const; + csz01 = str01.find_first_not_of(str_lit01, 0, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.find_first_not_of(str_lit01, 0, 8); + VERIFY( csz01 == 8 ); + csz01 = str01.find_first_not_of(str_lit01, 10, 0); + VERIFY( csz01 == 10 ); + + // size_type find_first_not_of(const char* s, size_type pos = 0) const; + csz01 = str01.find_first_not_of(str_lit01); + VERIFY( csz01 == 8 ); + csz01 = str02.find_first_not_of(str_lit01, 2); + VERIFY( csz01 == 2 ); + + // size_type find_first_not_of(char c, size_type pos = 0) const; + csz01 = str01.find_first_not_of(L'B'); + VERIFY( csz01 == 1 ); + csz01 = str01.find_first_not_of(L'o', 1); + VERIFY( csz01 == 2 ); + csz01 = str02.find_first_not_of(L'z'); + VERIFY( csz01 == 0 ); + csz01 = str04.find_first_not_of(L'S'); + VERIFY( csz01 == npos ); + return test; +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc new file mode 100644 index 00000000000..1357eb972d6 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc @@ -0,0 +1,42 @@ +// 2007-03-30 Paolo Carlini + +// Copyright (C) 2007-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.1 basic_string find + +#include +#include + +// libstdc++/31401 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + csize_type npos = std::wstring::npos; + + std::wstring use = L"anu"; + csize_type pos1 = use.find(L"a", npos); + + VERIFY( pos1 == npos ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/1.cc new file mode 100644 index 00000000000..0fa46d37b51 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/1.cc @@ -0,0 +1,92 @@ +// 2000-06-22 -=dbv=- (shamelessy copied from bkoz' find.cc) + +// Copyright (C) 2000-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// 21.3.6.2 basic_string rfind +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + typedef std::string::const_reference cref; + typedef std::string::reference ref; + csize_type npos = std::string::npos; + csize_type csz01, csz02; + + const char str_lit01[] = "mave"; + const std::string str01("mavericks, santa cruz"); + std::string str02(str_lit01); + std::string str03("s, s"); + std::string str04; + + // size_type rfind(const string&, size_type pos = 0) const; + csz01 = str01.rfind(str01); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str01, 4); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str02,3); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str02); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str03); + VERIFY( csz01 == 8 ); + csz01 = str01.rfind(str03, 3); + VERIFY( csz01 == npos ); + csz01 = str01.rfind(str03, 12); + VERIFY( csz01 == 8 ); + + // An empty string consists of no characters + // therefore it should be found at every point in a string, + // except beyond the end + csz01 = str01.rfind(str04, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str04, 5); + VERIFY( csz01 == 5 ); + csz01 = str01.rfind(str04, str01.size()); + VERIFY( csz01 == str01.size() ); + csz01 = str01.rfind(str04, str01.size()+1); + VERIFY( csz01 == str01.size() ); + + // size_type rfind(const char* s, size_type pos, size_type n) const; + csz01 = str01.rfind(str_lit01, 0, 3); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str_lit01, 3, 0); + VERIFY( csz01 == 3 ); + + // size_type rfind(const char* s, size_type pos = 0) const; + csz01 = str01.rfind(str_lit01); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str_lit01, 3); + VERIFY( csz01 == 0 ); + + // size_type rfind(char c, size_type pos = 0) const; + csz01 = str01.rfind('z'); + csz02 = str01.size() - 1; + VERIFY( csz01 == csz02 ); + csz01 = str01.rfind('/'); + VERIFY( csz01 == npos ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/2.cc new file mode 100644 index 00000000000..79f41d6b352 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/2.cc @@ -0,0 +1,50 @@ +// from tstring.cc, from jason merrill, et. al. + +// Copyright (C) 2000-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// 21.3.6.4 basic_string::find_last_of +bool test02() +{ + bool test __attribute__((unused)) = true; + std::string z("ab"); + std::string::size_type pos; + pos = z.find_last_of("ab"); + VERIFY( pos == 1 ); + pos = z.find_last_of("Xa"); + VERIFY( pos == 0 ); + pos = z.find_last_of("Xb"); + VERIFY( pos == 1 ); + pos = z.find_last_of("XYZ"); + VERIFY( pos == std::string::npos ); + pos = z.find_last_of('a'); + VERIFY( pos == 0 ); + pos = z.find_last_of('b'); + VERIFY( pos == 1 ); + pos = z.find_last_of('X'); + VERIFY( pos == std::string::npos ); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/3.cc new file mode 100644 index 00000000000..cbd327f7dc8 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/char/3.cc @@ -0,0 +1,64 @@ +// from tstring.cc, from jason merrill, et. al. + +// Copyright (C) 2000-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// 21.3.6.6 basic_string::find_last_not_of +bool test03() +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + std::string::size_type pos; + csize_type npos = std::string::npos; + + std::string x; + pos = x.find_last_not_of('X'); + VERIFY( pos == npos ); + pos = x.find_last_not_of("XYZ"); + VERIFY( pos == npos ); + + std::string y("a"); + pos = y.find_last_not_of('X'); + VERIFY( pos == 0 ); + pos = y.find_last_not_of('a'); + VERIFY( pos == npos ); + pos = y.find_last_not_of("XYZ"); + VERIFY( pos == 0 ); + pos = y.find_last_not_of("a"); + VERIFY( pos == npos ); + + std::string z("ab"); + pos = z.find_last_not_of('X'); + VERIFY( pos == 1 ); + pos = z.find_last_not_of("XYZ"); + VERIFY( pos == 1 ); + pos = z.find_last_not_of('b'); + VERIFY( pos == 0 ); + pos = z.find_last_not_of("Xb"); + VERIFY( pos == 0 ); + pos = z.find_last_not_of("Xa"); + VERIFY( pos == 1 ); + return test; +} +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/1.cc new file mode 100644 index 00000000000..9b4cecf9e85 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/1.cc @@ -0,0 +1,92 @@ +// 2000-06-22 -=dbv=- (shamelessy copied from bkoz' find.cc) + +// Copyright (C) 2000-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// 21.3.6.2 basic_string rfind +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + typedef std::wstring::const_reference cref; + typedef std::wstring::reference ref; + csize_type npos = std::wstring::npos; + csize_type csz01, csz02; + + const wchar_t str_lit01[] = L"mave"; + const std::wstring str01(L"mavericks, santa cruz"); + std::wstring str02(str_lit01); + std::wstring str03(L"s, s"); + std::wstring str04; + + // size_type rfind(const wstring&, size_type pos = 0) const; + csz01 = str01.rfind(str01); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str01, 4); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str02,3); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str02); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str03); + VERIFY( csz01 == 8 ); + csz01 = str01.rfind(str03, 3); + VERIFY( csz01 == npos ); + csz01 = str01.rfind(str03, 12); + VERIFY( csz01 == 8 ); + + // An empty string consists of no characters + // therefore it should be found at every point in a string, + // except beyond the end + csz01 = str01.rfind(str04, 0); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str04, 5); + VERIFY( csz01 == 5 ); + csz01 = str01.rfind(str04, str01.size()); + VERIFY( csz01 == str01.size() ); + csz01 = str01.rfind(str04, str01.size()+1); + VERIFY( csz01 == str01.size() ); + + // size_type rfind(const wchar_t* s, size_type pos, size_type n) const; + csz01 = str01.rfind(str_lit01, 0, 3); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str_lit01, 3, 0); + VERIFY( csz01 == 3 ); + + // size_type rfind(const wchar_t* s, size_type pos = 0) const; + csz01 = str01.rfind(str_lit01); + VERIFY( csz01 == 0 ); + csz01 = str01.rfind(str_lit01, 3); + VERIFY( csz01 == 0 ); + + // size_type rfind(wchar_t c, size_type pos = 0) const; + csz01 = str01.rfind(L'z'); + csz02 = str01.size() - 1; + VERIFY( csz01 == csz02 ); + csz01 = str01.rfind(L'/'); + VERIFY( csz01 == npos ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/2.cc new file mode 100644 index 00000000000..1b38b403ffc --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/2.cc @@ -0,0 +1,50 @@ +// from tstring.cc, from jason merrill, et. al. + +// Copyright (C) 2000-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// 21.3.6.4 basic_string::find_last_of +bool test02() +{ + bool test __attribute__((unused)) = true; + std::wstring::size_type pos; + std::wstring z(L"ab"); + pos = z.find_last_of(L"ab"); + VERIFY( pos == 1 ); + pos = z.find_last_of(L"Xa"); + VERIFY( pos == 0 ); + pos = z.find_last_of(L"Xb"); + VERIFY( pos == 1 ); + pos = z.find_last_of(L"XYZ"); + VERIFY( pos == std::wstring::npos ); + pos = z.find_last_of(L'a'); + VERIFY( pos == 0 ); + pos = z.find_last_of(L'b'); + VERIFY( pos == 1 ); + pos = z.find_last_of(L'X'); + VERIFY( pos == std::wstring::npos ); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/3.cc new file mode 100644 index 00000000000..5db1e49b39a --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/rfind/wchar_t/3.cc @@ -0,0 +1,64 @@ +// from tstring.cc, from jason merrill, et. al. + +// Copyright (C) 2000-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// 21.3.6.6 basic_string::find_last_not_of +bool test03() +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + std::wstring::size_type pos; + csize_type npos = std::wstring::npos; + + std::wstring x; + pos = x.find_last_not_of(L'X'); + VERIFY( pos == npos ); + pos = x.find_last_not_of(L"XYZ"); + VERIFY( pos == npos ); + + std::wstring y(L"a"); + pos = y.find_last_not_of(L'X'); + VERIFY( pos == 0 ); + pos = y.find_last_not_of(L'a'); + VERIFY( pos == npos ); + pos = y.find_last_not_of(L"XYZ"); + VERIFY( pos == 0 ); + pos = y.find_last_not_of(L"a"); + VERIFY( pos == npos ); + + std::wstring z(L"ab"); + pos = z.find_last_not_of(L'X'); + VERIFY( pos == 1 ); + pos = z.find_last_not_of(L"XYZ"); + VERIFY( pos == 1 ); + pos = z.find_last_not_of(L'b'); + VERIFY( pos == 0 ); + pos = z.find_last_not_of(L"Xb"); + VERIFY( pos == 0 ); + pos = z.find_last_not_of(L"Xa"); + VERIFY( pos == 1 ); + return test; +} +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/substr/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/substr/char/1.cc new file mode 100644 index 00000000000..463452fbdda --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/substr/char/1.cc @@ -0,0 +1,74 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1999-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.7 basic_string::substr + +#include +#include +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + typedef std::string::const_reference cref; + typedef std::string::reference ref; + csize_type csz01; + + const char str_lit01[] = "rockaway, pacifica"; + const std::string str01(str_lit01); + std::string str02; + + // basic_string + // substr(size_type pos = 0, size_type n = npos) const; + csz01 = str01.size(); + str02 = str01.substr(0, 1); + VERIFY( str02 == "r" ); + str02 = str01.substr(10); + VERIFY( str02 == "pacifica" ); + + try { + str02 = str01.substr(csz01 + 1); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + try { + str02 = str01.substr(csz01); + VERIFY( str02.size() == 0 ); + } + catch(std::out_of_range& fail) { + VERIFY( false ); + } + catch(...) { + VERIFY( false ); + } + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/substr/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/substr/wchar_t/1.cc new file mode 100644 index 00000000000..ff3ecc890e2 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/substr/wchar_t/1.cc @@ -0,0 +1,74 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1999-2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 21.3.6.7 basic_string::substr + +#include +#include +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + typedef std::wstring::const_reference cref; + typedef std::wstring::reference ref; + csize_type csz01; + + const wchar_t str_lit01[] = L"rockaway, pacifica"; + const std::wstring str01(str_lit01); + std::wstring str02; + + // basic_string + // substr(size_type pos = 0, size_type n = npos) const; + csz01 = str01.size(); + str02 = str01.substr(0, 1); + VERIFY( str02 == L"r" ); + str02 = str01.substr(10); + VERIFY( str02 == L"pacifica" ); + + try { + str02 = str01.substr(csz01 + 1); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + try { + str02 = str01.substr(csz01); + VERIFY( str02.size() == 0 ); + } + catch(std::out_of_range& fail) { + VERIFY( false ); + } + catch(...) { + VERIFY( false ); + } + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/wchar_t/1.cc deleted file mode 100644 index 97b5d4afcec..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/wchar_t/1.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2004-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6 string operations - -#include -#include - -int test01(void) -{ - bool test __attribute__((unused)) = true; - - std::wstring empty; - - // data() for size == 0 is non-NULL. - VERIFY( empty.size() == 0 ); - const std::wstring::value_type* p = empty.data(); - VERIFY( p ); - - return 0; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/1.cc deleted file mode 100644 index 0fa46d37b51..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/1.cc +++ /dev/null @@ -1,92 +0,0 @@ -// 2000-06-22 -=dbv=- (shamelessy copied from bkoz' find.cc) - -// Copyright (C) 2000-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// 21.3.6.2 basic_string rfind -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - typedef std::string::const_reference cref; - typedef std::string::reference ref; - csize_type npos = std::string::npos; - csize_type csz01, csz02; - - const char str_lit01[] = "mave"; - const std::string str01("mavericks, santa cruz"); - std::string str02(str_lit01); - std::string str03("s, s"); - std::string str04; - - // size_type rfind(const string&, size_type pos = 0) const; - csz01 = str01.rfind(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str01, 4); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02,3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str03); - VERIFY( csz01 == 8 ); - csz01 = str01.rfind(str03, 3); - VERIFY( csz01 == npos ); - csz01 = str01.rfind(str03, 12); - VERIFY( csz01 == 8 ); - - // An empty string consists of no characters - // therefore it should be found at every point in a string, - // except beyond the end - csz01 = str01.rfind(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.rfind(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.rfind(str04, str01.size()+1); - VERIFY( csz01 == str01.size() ); - - // size_type rfind(const char* s, size_type pos, size_type n) const; - csz01 = str01.rfind(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type rfind(const char* s, size_type pos = 0) const; - csz01 = str01.rfind(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3); - VERIFY( csz01 == 0 ); - - // size_type rfind(char c, size_type pos = 0) const; - csz01 = str01.rfind('z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.rfind('/'); - VERIFY( csz01 == npos ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/2.cc deleted file mode 100644 index 79f41d6b352..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/2.cc +++ /dev/null @@ -1,50 +0,0 @@ -// from tstring.cc, from jason merrill, et. al. - -// Copyright (C) 2000-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// 21.3.6.4 basic_string::find_last_of -bool test02() -{ - bool test __attribute__((unused)) = true; - std::string z("ab"); - std::string::size_type pos; - pos = z.find_last_of("ab"); - VERIFY( pos == 1 ); - pos = z.find_last_of("Xa"); - VERIFY( pos == 0 ); - pos = z.find_last_of("Xb"); - VERIFY( pos == 1 ); - pos = z.find_last_of("XYZ"); - VERIFY( pos == std::string::npos ); - pos = z.find_last_of('a'); - VERIFY( pos == 0 ); - pos = z.find_last_of('b'); - VERIFY( pos == 1 ); - pos = z.find_last_of('X'); - VERIFY( pos == std::string::npos ); - return test; -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/3.cc deleted file mode 100644 index cbd327f7dc8..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/3.cc +++ /dev/null @@ -1,64 +0,0 @@ -// from tstring.cc, from jason merrill, et. al. - -// Copyright (C) 2000-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// 21.3.6.6 basic_string::find_last_not_of -bool test03() -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - std::string::size_type pos; - csize_type npos = std::string::npos; - - std::string x; - pos = x.find_last_not_of('X'); - VERIFY( pos == npos ); - pos = x.find_last_not_of("XYZ"); - VERIFY( pos == npos ); - - std::string y("a"); - pos = y.find_last_not_of('X'); - VERIFY( pos == 0 ); - pos = y.find_last_not_of('a'); - VERIFY( pos == npos ); - pos = y.find_last_not_of("XYZ"); - VERIFY( pos == 0 ); - pos = y.find_last_not_of("a"); - VERIFY( pos == npos ); - - std::string z("ab"); - pos = z.find_last_not_of('X'); - VERIFY( pos == 1 ); - pos = z.find_last_not_of("XYZ"); - VERIFY( pos == 1 ); - pos = z.find_last_not_of('b'); - VERIFY( pos == 0 ); - pos = z.find_last_not_of("Xb"); - VERIFY( pos == 0 ); - pos = z.find_last_not_of("Xa"); - VERIFY( pos == 1 ); - return test; -} -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/1.cc deleted file mode 100644 index 9b4cecf9e85..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/1.cc +++ /dev/null @@ -1,92 +0,0 @@ -// 2000-06-22 -=dbv=- (shamelessy copied from bkoz' find.cc) - -// Copyright (C) 2000-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// 21.3.6.2 basic_string rfind -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - typedef std::wstring::const_reference cref; - typedef std::wstring::reference ref; - csize_type npos = std::wstring::npos; - csize_type csz01, csz02; - - const wchar_t str_lit01[] = L"mave"; - const std::wstring str01(L"mavericks, santa cruz"); - std::wstring str02(str_lit01); - std::wstring str03(L"s, s"); - std::wstring str04; - - // size_type rfind(const wstring&, size_type pos = 0) const; - csz01 = str01.rfind(str01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str01, 4); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02,3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str02); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str03); - VERIFY( csz01 == 8 ); - csz01 = str01.rfind(str03, 3); - VERIFY( csz01 == npos ); - csz01 = str01.rfind(str03, 12); - VERIFY( csz01 == 8 ); - - // An empty string consists of no characters - // therefore it should be found at every point in a string, - // except beyond the end - csz01 = str01.rfind(str04, 0); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str04, 5); - VERIFY( csz01 == 5 ); - csz01 = str01.rfind(str04, str01.size()); - VERIFY( csz01 == str01.size() ); - csz01 = str01.rfind(str04, str01.size()+1); - VERIFY( csz01 == str01.size() ); - - // size_type rfind(const wchar_t* s, size_type pos, size_type n) const; - csz01 = str01.rfind(str_lit01, 0, 3); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3, 0); - VERIFY( csz01 == 3 ); - - // size_type rfind(const wchar_t* s, size_type pos = 0) const; - csz01 = str01.rfind(str_lit01); - VERIFY( csz01 == 0 ); - csz01 = str01.rfind(str_lit01, 3); - VERIFY( csz01 == 0 ); - - // size_type rfind(wchar_t c, size_type pos = 0) const; - csz01 = str01.rfind(L'z'); - csz02 = str01.size() - 1; - VERIFY( csz01 == csz02 ); - csz01 = str01.rfind(L'/'); - VERIFY( csz01 == npos ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/2.cc deleted file mode 100644 index 1b38b403ffc..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/2.cc +++ /dev/null @@ -1,50 +0,0 @@ -// from tstring.cc, from jason merrill, et. al. - -// Copyright (C) 2000-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// 21.3.6.4 basic_string::find_last_of -bool test02() -{ - bool test __attribute__((unused)) = true; - std::wstring::size_type pos; - std::wstring z(L"ab"); - pos = z.find_last_of(L"ab"); - VERIFY( pos == 1 ); - pos = z.find_last_of(L"Xa"); - VERIFY( pos == 0 ); - pos = z.find_last_of(L"Xb"); - VERIFY( pos == 1 ); - pos = z.find_last_of(L"XYZ"); - VERIFY( pos == std::wstring::npos ); - pos = z.find_last_of(L'a'); - VERIFY( pos == 0 ); - pos = z.find_last_of(L'b'); - VERIFY( pos == 1 ); - pos = z.find_last_of(L'X'); - VERIFY( pos == std::wstring::npos ); - return test; -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/3.cc deleted file mode 100644 index 5db1e49b39a..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/3.cc +++ /dev/null @@ -1,64 +0,0 @@ -// from tstring.cc, from jason merrill, et. al. - -// Copyright (C) 2000-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -#include -#include - -// 21.3.6.6 basic_string::find_last_not_of -bool test03() -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - std::wstring::size_type pos; - csize_type npos = std::wstring::npos; - - std::wstring x; - pos = x.find_last_not_of(L'X'); - VERIFY( pos == npos ); - pos = x.find_last_not_of(L"XYZ"); - VERIFY( pos == npos ); - - std::wstring y(L"a"); - pos = y.find_last_not_of(L'X'); - VERIFY( pos == 0 ); - pos = y.find_last_not_of(L'a'); - VERIFY( pos == npos ); - pos = y.find_last_not_of(L"XYZ"); - VERIFY( pos == 0 ); - pos = y.find_last_not_of(L"a"); - VERIFY( pos == npos ); - - std::wstring z(L"ab"); - pos = z.find_last_not_of(L'X'); - VERIFY( pos == 1 ); - pos = z.find_last_not_of(L"XYZ"); - VERIFY( pos == 1 ); - pos = z.find_last_not_of(L'b'); - VERIFY( pos == 0 ); - pos = z.find_last_not_of(L"Xb"); - VERIFY( pos == 0 ); - pos = z.find_last_not_of(L"Xa"); - VERIFY( pos == 1 ); - return test; -} -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/substr/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/substr/char/1.cc deleted file mode 100644 index 463452fbdda..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/substr/char/1.cc +++ /dev/null @@ -1,74 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1999-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.7 basic_string::substr - -#include -#include -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - typedef std::string::const_reference cref; - typedef std::string::reference ref; - csize_type csz01; - - const char str_lit01[] = "rockaway, pacifica"; - const std::string str01(str_lit01); - std::string str02; - - // basic_string - // substr(size_type pos = 0, size_type n = npos) const; - csz01 = str01.size(); - str02 = str01.substr(0, 1); - VERIFY( str02 == "r" ); - str02 = str01.substr(10); - VERIFY( str02 == "pacifica" ); - - try { - str02 = str01.substr(csz01 + 1); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - try { - str02 = str01.substr(csz01); - VERIFY( str02.size() == 0 ); - } - catch(std::out_of_range& fail) { - VERIFY( false ); - } - catch(...) { - VERIFY( false ); - } - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/substr/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/substr/wchar_t/1.cc deleted file mode 100644 index ff3ecc890e2..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/substr/wchar_t/1.cc +++ /dev/null @@ -1,74 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1999-2013 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see -// . - -// 21.3.6.7 basic_string::substr - -#include -#include -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - typedef std::wstring::const_reference cref; - typedef std::wstring::reference ref; - csize_type csz01; - - const wchar_t str_lit01[] = L"rockaway, pacifica"; - const std::wstring str01(str_lit01); - std::wstring str02; - - // basic_string - // substr(size_type pos = 0, size_type n = npos) const; - csz01 = str01.size(); - str02 = str01.substr(0, 1); - VERIFY( str02 == L"r" ); - str02 = str01.substr(10); - VERIFY( str02 == L"pacifica" ); - - try { - str02 = str01.substr(csz01 + 1); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - try { - str02 = str01.substr(csz01); - VERIFY( str02.size() == 0 ); - } - catch(std::out_of_range& fail) { - VERIFY( false ); - } - catch(...) { - VERIFY( false ); - } - return test; -} - -int main() -{ - test01(); - return 0; -}