From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- .../21_strings/basic_string/replace/wchar_t/1.cc | 82 ++++++++++++++++++++++ .../21_strings/basic_string/replace/wchar_t/2.cc | 47 +++++++++++++ .../21_strings/basic_string/replace/wchar_t/3.cc | 74 +++++++++++++++++++ .../21_strings/basic_string/replace/wchar_t/4.cc | 67 ++++++++++++++++++ .../21_strings/basic_string/replace/wchar_t/5.cc | 43 ++++++++++++ .../21_strings/basic_string/replace/wchar_t/6.cc | 54 ++++++++++++++ 6 files changed, 367 insertions(+) create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc (limited to 'libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t') diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc new file mode 100644 index 000000000..c3afcafac --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc @@ -0,0 +1,82 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +// 2003, 2004, 2005, 2006, 2007, 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include // for std::find +#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; + + const wchar_t str_lit01[] = L"ventura, california"; + const std::wstring str01(str_lit01); + std::wstring str02(L"del mar, california"); + std::wstring str03(L" and "); + std::wstring str05; + + // wstring& replace(size_type pos, size_type n, const wstring& string) + // wstring& replace(size_type pos1, size_type n1, const wstring& string, + // size_type pos2, size_type n2) + // wstring& replace(size_type pos, size_type n1, const wchar_t* s, size_type n2) + // wstring& replace(size_type pos, size_type n1, const wchar_t* s) + // wstring& replace(size_type pos, size_type n1, size_type n2, wchar_t c) + // wstring& replace(iterator it1, iterator it2, const wstring& str) + // wstring& replace(iterator it1, iterator it2, const wchar_t* s, size_type n) + // wstring& replace(iterator it1, iterator it2, const wchar_t* s) + // wstring& replace(iterator it1, iterator it2, size_type n, char c) + // template + // wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) + + // with mods, from tstring.cc, from jason merrill, et. al. + std::wstring X = L"Hello"; + std::wstring x = X; + + wchar_t ch = x[0]; + VERIFY( ch == L'H' ); + + std::wstring z = x.substr(2, 3); + VERIFY( z == L"llo" ); + + x.replace(2, 2, L"r"); + VERIFY( x == L"Hero" ); + + x = X; + x.replace(0, 1, L"j"); + VERIFY( x == L"jello" ); + + wchar_t ar[] = { L'H', L'e', L'l', L'l', L'o' }; + x.replace(std::find(x.begin(), x.end(), L'l'), + std::find(x.rbegin(), x.rend(), L'l').base(), ar, + ar + sizeof(ar) / sizeof(ar[0])); + VERIFY( x == L"jeHelloo" ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc new file mode 100644 index 000000000..83008ba14 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc @@ -0,0 +1,47 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994, 1999, 2001, 2002, 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include +#include + +void +test02() +{ + bool test __attribute__((unused)) = true; + const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii"; + std::wstring aux = strlit; + aux.replace(aux.begin()+5, aux.begin()+20, + aux.begin()+10, aux.begin()+15); + VERIFY(aux == L"../thg piealei Bay/Kauai/Hawaii"); + + aux = strlit; + aux.replace(aux.begin() + 10, aux.begin() + 15, + aux.begin() + 5, aux.begin() + 20); + VERIFY(aux == L"../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii"); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc new file mode 100644 index 000000000..34031673c --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc @@ -0,0 +1,74 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994, 1999, 2001, 2002, 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// Some more miscellaneous tests +void +test03() +{ + bool test __attribute__((unused)) = true; + const wchar_t* title01 = L"nine types of ambiguity"; + const wchar_t* title02 = L"ultra"; + std::wstring str01 = title01; + std::wstring str02 = title02; + + str01.replace(0, 4, str02); + VERIFY(str01 == L"ultra types of ambiguity"); + + str01.replace(15, 9, str02, 2, 2); + VERIFY(str01 == L"ultra types of tr"); + + str01 = title01; + str02.replace(0, 0, str01, 0, std::wstring::npos); + VERIFY(str02 == L"nine types of ambiguityultra"); + + str02.replace(11, 2, title02, 5); + VERIFY(str02 == L"nine types ultra ambiguityultra"); + + str02.replace(11, 5, title01, 2); + VERIFY(str02 == L"nine types ni ambiguityultra"); + + str01.replace(str01.size(), 0, title02); + VERIFY(str01 == L"nine types of ambiguityultra"); + + str01 = title01; + str02 = title02; + str01.replace(str01.begin(), str01.end(), str02); + VERIFY(str01 == L"ultra"); + + str01.replace(str01.begin(), str01.begin(), title01, 4); + VERIFY(str01 == L"nineultra"); + + str01.replace(str01.end(), str01.end(), title01 + 5, 5); + VERIFY(str01 == L"nineultratypes"); + + str01.replace(str01.begin(), str01.end(), title02); + VERIFY(str01 == L"ultra"); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc new file mode 100644 index 000000000..60d6a1579 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc @@ -0,0 +1,67 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994, 1999, 2001, 2002, 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// Some more tests for +// template +// wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) +void +test04() +{ + bool test __attribute__((unused)) = true; + std::wstring str01 = L"geogaddi"; + std::wstring str02; + + typedef std::wstring::iterator iterator; + typedef std::wstring::const_iterator const_iterator; + + iterator it1 = str01.begin(); + iterator it2 = str01.end(); + str02.replace(str02.begin(), str02.end(), it1, it2); + VERIFY(str02 == L"geogaddi"); + + str02 = L"boards"; + const_iterator c_it1 = str01.begin(); + const_iterator c_it2 = str01.end(); + str02.replace(str02.begin(), str02.end(), c_it1, c_it2); + VERIFY(str02 == L"geogaddi"); + + str02 = L"boards"; + const wchar_t* c_ptr1 = str01.c_str(); + const wchar_t* c_ptr2 = str01.c_str() + 8; + str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2); + VERIFY(str02 == L"geogaddi"); + + str02 = L"boards"; + wchar_t* ptr1 = &*str01.begin(); + wchar_t* ptr2 = ptr1 + str01.length(); + str02.replace(str02.begin(), str02.end(), ptr1, ptr2); + VERIFY(str02 == L"geogaddi"); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc new file mode 100644 index 000000000..959b515b4 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc @@ -0,0 +1,43 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994, 1999, 2001, 2002, 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// We wrongly used __n1 instead of __foldn1 in the length_error +// check at the beginning of replace(__pos, __n1, __s, __n2) +void +test05() +{ + bool test __attribute__((unused)) = true; + std::wstring str01 = L"londinium"; + std::wstring str02 = L"cydonia"; + + str01.replace(0, 20, str02.c_str(), 3); + VERIFY(str01 == L"cyd"); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc new file mode 100644 index 000000000..98c236cf6 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc @@ -0,0 +1,54 @@ +// 2004-01-26 Paolo Carlini + +// Copyright (C) 2004, 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::wstring str01(L"Valle Del Salto"); + str01.replace(0, 5, str01.data() + 10, 5); + VERIFY( str01 == L"Salto Del Salto" ); + + std::wstring str02(L"Colle di Val d'Elsa"); + str02.replace(0, 9, str02.data() + 10, 0); + VERIFY( str02 == L"Val d'Elsa" ); + + std::wstring str03(L"Novi Ligure"); + str03.replace(11, 0, str03.data() + 4, 7); + VERIFY( str03 == L"Novi Ligure Ligure"); + + std::wstring str04(L"Trebisacce"); + str04.replace(3, 4, str04.data(), 0); + VERIFY( str04 == L"Trecce" ); + + std::wstring str05(L"Altopiano della Sila"); + str05.replace(1, 18, str05.data() + 19, 1); + VERIFY( str05 == L"Aaa" ); +} + +int main() +{ + test01(); + return 0; +} -- cgit v1.2.3