diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t')
4 files changed, 515 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc new file mode 100644 index 000000000..3bdc0d25b --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc @@ -0,0 +1,49 @@ +// 1999-05-07 bkoz + +// Copyright (C) 1999, 2003, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.3.6 string operations + +#include <string> +#include <cstdio> +#include <testsuite_hooks.h> + +int test01(void) +{ + bool test __attribute__((unused)) = true; + + std::wstring str1; + std::wstring str2; + + // Should get this: + // 1:8-chars_8-chars_ + // 2:8-chars_8-chars_ + str1 = std::wstring(L"8-chars_") + L"8-chars_"; + str1.c_str(); + // wprintf("1:%s\n", str1.c_str()); + str2 = str1 + L"7-chars"; + // wprintf("2:%s\n", str1.c_str()); //str1 is gone + str1.c_str(); + return 0; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc new file mode 100644 index 000000000..a563f5377 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc @@ -0,0 +1,294 @@ +// 1998-10-01, 1999-06-25 bkoz + +// Copyright (C) 1998, 1999, 2003, 2009 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 +// <http://www.gnu.org/licenses/>. + +// 21.3.7.1 basic_string non-member functions + +// 21.3.7.2 operator== +/* +template<class charT, class traits, class Allocator> + bool operator==(const basic_string<charT,traits,Allocator>& lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator==(const charT* lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator==(const basic_string<charT,traits,Allocator>& lhs, + const charT* rhs); +*/ + +// 21.3.7.3 operator!= +/* +template<class charT, class traits, class Allocator> + bool operator!=(const basic_string<charT,traits,Allocator>& lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator!=(const charT* lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator!=(const basic_string<charT,traits,Allocator>& lhs, + const charT* rhs); +*/ + +// 21.3.7.4 operator< +/* +template<class charT, class traits, class Allocator> + bool operator< (const basic_string<charT,traits,Allocator>& lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator< (const basic_string<charT,traits,Allocator>& lhs, + const charT* rhs); + +template<class charT, class traits, class Allocator> + bool operator< (const charT* lhs, + const basic_string<charT,traits,Allocator>& rhs); +*/ + +// 21.3.7.5 operator> +/* +template<class charT, class traits, class Allocator> + bool operator> (const basic_string<charT,traits,Allocator>& lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator> (const basic_string<charT,traits,Allocator>& lhs, + const charT* rhs); + +template<class charT, class traits, class Allocator> + bool operator> (const charT* lhs, + const basic_string<charT,traits,Allocator>& rhs); +*/ + +//21.3.7.6 operator<= +/* +template<class charT, class traits, class Allocator> + bool operator<=(const basic_string<charT,traits,Allocator>& lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator<=(const basic_string<charT,traits,Allocator>& lhs, + const charT* rhs); + +template<class charT, class traits, class Allocator> + bool operator<=(const charT* lhs, + const basic_string<charT,traits,Allocator>& rhs); +*/ + +// 21.3.7.7 operator>= +/* +template<class charT, class traits, class Allocator> + bool operator>=(const basic_string<charT,traits,Allocator>& lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + bool operator>=(const basic_string<charT,traits,Allocator>& lhs, + const charT* rhs); + +template<class charT, class traits, class Allocator> + bool operator>=(const charT* lhs, + const basic_string<charT,traits,Allocator>& rhs); +*/ + +#include <string> +#include <testsuite_hooks.h> + +int test01(void) +{ + bool test __attribute__((unused)) = true; + std::wstring str_0(L"costa rica"); + std::wstring str_1(L"costa marbella"); + std::wstring str_2(L"cost"); + std::wstring str_3(L"costa ricans"); + std::wstring str_4; + + str_4 = str_0; + //comparisons between string objects + VERIFY( !(str_0 == str_1) ); + VERIFY( !(str_0 == str_2) ); + VERIFY( !(str_0 == str_3) ); + VERIFY( !(str_1 == str_0) ); + VERIFY( !(str_2 == str_0) ); + VERIFY( !(str_3 == str_0) ); + VERIFY( str_4 == str_0 ); + VERIFY( str_0 == str_4 ); + + VERIFY( str_0 != str_1 ); + VERIFY( str_0 != str_2 ); + VERIFY( str_0 != str_3 ); + VERIFY( str_1 != str_0 ); + VERIFY( str_2 != str_0 ); + VERIFY( str_3 != str_0 ); + VERIFY( !(str_0 != str_4) ); + VERIFY( !(str_4 != str_0) ); + + VERIFY( str_0 > str_1 ); //true cuz r>m + VERIFY( str_0 > str_2 ); + VERIFY( !(str_0 > str_3) ); + VERIFY( !(str_1 > str_0) ); //false cuz m<r + VERIFY( !(str_2 > str_0) ); + VERIFY( str_3 > str_0 ); + VERIFY( !(str_0 > str_4) ); + VERIFY( !(str_4 > str_0) ); + + VERIFY( !(str_0 < str_1) ); //false cuz r>m + VERIFY( !(str_0 < str_2) ); + VERIFY( str_0 < str_3 ); + VERIFY( str_1 < str_0 ); //true cuz m<r + VERIFY( str_2 < str_0 ); + VERIFY( !(str_3 < str_0) ); + VERIFY( !(str_0 < str_4) ); + VERIFY( !(str_4 < str_0) ); + + VERIFY( str_0 >= str_1 ); //true cuz r>m + VERIFY( str_0 >= str_2 ); + VERIFY( !(str_0 >= str_3) ); + VERIFY( !(str_1 >= str_0) );//false cuz m<r + VERIFY( !(str_2 >= str_0) ); + VERIFY( str_3 >= str_0 ); + VERIFY( str_0 >= str_4 ); + VERIFY( str_4 >= str_0 ); + + VERIFY( !(str_0 <= str_1) );//false cuz r>m + VERIFY( !(str_0 <= str_2) ); + VERIFY( str_0 <= str_3 ); + VERIFY( str_1 <= str_0 );//true cuz m<r + VERIFY( str_2 <= str_0 ); + VERIFY( !(str_3 <= str_0) ); + VERIFY( str_0 <= str_4 ); + VERIFY( str_4 <= str_0 ); + + //comparisons between string object and string literal + VERIFY( !(str_0 == L"costa marbella") ); + VERIFY( !(str_0 == L"cost") ); + VERIFY( !(str_0 == L"costa ricans") ); + VERIFY( !(L"costa marbella" == str_0) ); + VERIFY( !(L"cost" == str_0) ); + VERIFY( !(L"costa ricans" == str_0) ); + VERIFY( L"costa rica" == str_0 ); + VERIFY( str_0 == L"costa rica" ); + + VERIFY( str_0 != L"costa marbella" ); + VERIFY( str_0 != L"cost" ); + VERIFY( str_0 != L"costa ricans" ); + VERIFY( L"costa marbella" != str_0 ); + VERIFY( L"cost" != str_0 ); + VERIFY( L"costa ricans" != str_0 ); + VERIFY( !(L"costa rica" != str_0) ); + VERIFY( !(str_0 != L"costa rica") ); + + VERIFY( str_0 > L"costa marbella" ); //true cuz r>m + VERIFY( str_0 > L"cost" ); + VERIFY( !(str_0 > L"costa ricans") ); + VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r + VERIFY( !(L"cost" > str_0) ); + VERIFY( L"costa ricans" > str_0 ); + VERIFY( !(L"costa rica" > str_0) ); + VERIFY( !(str_0 > L"costa rica") ); + + VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m + VERIFY( !(str_0 < L"cost") ); + VERIFY( str_0 < L"costa ricans" ); + VERIFY( L"costa marbella" < str_0 );//true cuz m<r + VERIFY( L"cost" < str_0 ); + VERIFY( !(L"costa ricans" < str_0) ); + VERIFY( !(L"costa rica" < str_0) ); + VERIFY( !(str_0 < L"costa rica") ); + + VERIFY( str_0 >= L"costa marbella" );//true cuz r>m + VERIFY( str_0 >= L"cost" ); + VERIFY( !(str_0 >= L"costa ricans") ); + VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r + VERIFY( !(L"cost" >= str_0) ); + VERIFY( L"costa ricans" >= str_0 ); + VERIFY( L"costa rica" >= str_0 ); + VERIFY( str_0 >= L"costa rica" ); + + VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m + VERIFY( !(str_0 <= L"cost") ); + VERIFY( str_0 <= L"costa ricans" ); + VERIFY( L"costa marbella" <= str_0 );//true cuz m<r + VERIFY( L"cost" <= str_0 ); + VERIFY( !(L"costa ricans" <= str_0) ); + VERIFY( L"costa rica" <= str_0 ); + VERIFY( str_0 <= L"costa rica" ); + + // 21.3.7.1 operator+ +/* +template<class charT, class traits, class Allocator> + basic_string<charT,traits,Allocator> + operator+(const basic_string<charT,traits,Allocator>& lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + basic_string<charT,traits,Allocator> + operator+(const charT* lhs, + const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + basic_string<charT,traits,Allocator> + operator+(const basic_string<charT,traits,Allocator>& lhs, + const charT* rhs); + +template<class charT, class traits, class Allocator> + basic_string<charT,traits,Allocator> + operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); + +template<class charT, class traits, class Allocator> + basic_string<charT,traits,Allocator> + operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs); +*/ + + str_4 = str_0 + L"ns"; + VERIFY( str_4 == str_3 ); + + const std::wstring str_5(L" marbella"); + str_4 = L"costa" + str_5; + VERIFY( str_4 == str_1 ); + + std::wstring str_6(L"ns"); + str_4 = str_0 + str_6; + VERIFY( str_4 == str_3 ); + + str_4 = str_0 + L'n'; + str_4 = str_4 + L's'; + VERIFY( str_4 == str_3 ); + + str_4 = L'a' + str_6; + str_4 = L'c' + str_4; + str_4 = L'i' + str_4; + str_4 = L'r' + str_4; + str_4 = L' ' + str_4; + str_4 = L'a' + str_4; + str_4 = L't' + str_4; + str_4 = L's' + str_4; + str_4 = L'o' + str_4; + str_4 = L'c' + str_4; + VERIFY( str_4 == str_3 ); + return 0; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/3.cc new file mode 100644 index 000000000..77915f5e3 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/3.cc @@ -0,0 +1,93 @@ +// 2010-12-17 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + +#include <string> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::wstring; + + VERIFY( (wstring(L"abc") + wstring(L"def") + == wstring(L"abcdef")) ); + wstring s1(L"abc"); + VERIFY( s1 + wstring(L"def") == wstring(L"abcdef") ); + wstring s2(L"def"); + VERIFY( wstring(L"abc") + s2 == wstring(L"abcdef") ); + VERIFY( wstring(L"abc") + L'd' == wstring(L"abcd") ); + VERIFY( wstring(L"abc") + L"def" == wstring(L"abcdef") ); + VERIFY( L'a' + wstring(L"bcd") == wstring(L"abcd") ); + VERIFY( L"abc" + wstring(L"def") == wstring(L"abcdef") ); + + VERIFY( (wstring(L"abcdefghij") + wstring(L"klmnopqrst") + == wstring(L"abcdefghijklmnopqrst")) ); + wstring s1l(L"abcdefghij"); + VERIFY( (s1l + wstring(L"klmnopqrst") + == wstring(L"abcdefghijklmnopqrst")) ); + wstring s2l(L"klmnopqrst"); + VERIFY( (wstring(L"abcdefghij") + s2l + == wstring(L"abcdefghijklmnopqrst")) ); + VERIFY( (wstring(L"abcdefghijklmno") + L'p' + == wstring(L"abcdefghijklmnop")) ); + VERIFY( (wstring(L"abcdefghijklmno") + L"pqrst" + == wstring(L"abcdefghijklmnopqrst")) ); + VERIFY( (L'a' + wstring(L"bcdefghijklmnop") + == wstring(L"abcdefghijklmnop")) ); + VERIFY( (L"abcde" + wstring(L"fghijklmnopqrst") + == wstring(L"abcdefghijklmnopqrst")) ); + + VERIFY( (wstring(L"abcdefghijklmnopqrst") + wstring(L"uvwxy") + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + VERIFY( (wstring(L"abcde") + wstring(L"fghijklmnopqrstuvwxy") + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + wstring s1ll1(L"abcdefghijklmnopqrst"); + VERIFY( (s1ll1 + wstring(L"uvwxy") + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + wstring s1ll2(L"abcde"); + VERIFY( (s1ll2 + wstring(L"fghijklmnopqrstuvwxy") + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + wstring s2ll1(L"fghijklmnopqrstuvwxy"); + VERIFY( (wstring(L"abcde") + s2ll1 + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + wstring s2ll2(L"uvwxy"); + VERIFY( (wstring(L"abcdefghijklmnopqrst") + s2ll2 + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + VERIFY( (wstring(L"abcdefghijklmnopqrst") + L'u' + == wstring(L"abcdefghijklmnopqrstu")) ); + VERIFY( (wstring(L"abcdefghijklmnopqrst") + L"uvwxy" + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + VERIFY( (wstring(L"abcde") + L"fghijklmnopqrstuvwxy" + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + VERIFY( (L'a' + wstring(L"bcdefghijklmnopqrstuvwxy") + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + VERIFY( (L"abcde" + wstring(L"fghijklmnopqrstuvwxy") + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); + VERIFY( (L"abcdefghijklmnopqrst" + wstring(L"uvwxy") + == wstring(L"abcdefghijklmnopqrstuvwxy")) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/4.cc new file mode 100644 index 000000000..36e307d65 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/4.cc @@ -0,0 +1,79 @@ +// 2010-12-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 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 +// <http://www.gnu.org/licenses/>. +// +// { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + +#include <string> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::wstring; + using std::move; + + wstring s01(L"abc"); + s01.reserve(30); + wstring s02(L"def"); + s02.reserve(30); + VERIFY( move(s01) + move(s02) == wstring(L"abcdef") ); + + wstring s03(L"abcdefghijklmnopqrstuvw"); + wstring s04(L"xyz"); + s04.reserve(30); + VERIFY( move(s03) + move(s04) == wstring(L"abcdefghijklmnopqrstuvwxyz") ); + + wstring s05(L"abc"); + s05.reserve(30); + wstring s06(L"defghijklmnopqrstuvwxyz"); + VERIFY( move(s05) + move(s06) == wstring(L"abcdefghijklmnopqrstuvwxyz") ); + + const wstring sc1(L"abc"); + wstring s07(L"def"); + s07.reserve(30); + VERIFY( sc1 + move(s07) == wstring(L"abcdef") ); + + const wstring sc2(L"def"); + wstring s08(L"abc"); + s08.reserve(30); + VERIFY( move(s08) + sc2 == wstring(L"abcdef") ); + + wstring s09(L"abc"); + s09.reserve(30); + VERIFY( move(s09) + L'd' == wstring(L"abcd") ); + + wstring s10(L"abc"); + s10.reserve(30); + VERIFY( move(s10) + L"def" == wstring(L"abcdef") ); + + wstring s11(L"bcd"); + s11.reserve(30); + VERIFY( L'a' + move(s11) == wstring(L"abcd") ); + + wstring s12(L"def"); + s12.reserve(30); + VERIFY( L"abc" + move(s12) == wstring(L"abcdef") ); +} + +int main() +{ + test01(); + return 0; +} |