diff options
author | Lancelot Six <lancelot.six@amd.com> | 2023-10-13 10:23:59 +0000 |
---|---|---|
committer | Lancelot Six <lancelot.six@amd.com> | 2023-11-21 11:52:36 +0000 |
commit | 393be56421a81e44c8728c8b31df66b319697398 (patch) | |
tree | 9c173828a2b54aeac5329a1acd9cdcb90a36b8f5 /gdb/unittests/basic_string_view/inserters | |
parent | 882b0505164f9474ef565cbc237df34a65061a8f (diff) | |
download | gdb-393be56421a81e44c8728c8b31df66b319697398.zip gdb-393be56421a81e44c8728c8b31df66b319697398.tar.gz gdb-393be56421a81e44c8728c8b31df66b319697398.tar.bz2 |
gdbsupport: Remove gdb::string_view
Now that all places using gdb::string_view have been updated to use
std::string_view, this patch drops the gdb::string_view implementation
and the tests which came with it.
As this drops the unittests/string_view-selftests.c, this also
implicitly solves PR build/23676, as pointed-out by Tom Tromey.
Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23676
Diffstat (limited to 'gdb/unittests/basic_string_view/inserters')
7 files changed, 0 insertions, 499 deletions
diff --git a/gdb/unittests/basic_string_view/inserters/char/1.cc b/gdb/unittests/basic_string_view/inserters/char/1.cc deleted file mode 100644 index e0a33bf..0000000 --- a/gdb/unittests/basic_string_view/inserters/char/1.cc +++ /dev/null @@ -1,65 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 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/>. - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include <string_view> -#include <stdexcept> -#include <sstream> -#include <fstream> -#include <iostream> -#include <testsuite_hooks.h> - -void -test01() -{ - typedef std::string_view::size_type csize_type; - typedef std::string_view::const_reference cref; - typedef std::string_view::reference ref; - - const std::string_view str01("sailing grand traverse bay\n" - "\t\t\t from Elk Rapids to the point reminds me of miles"); - - // ostream& operator<<(ostream&, const basic_string_view&) - std::ostringstream ostrs01; - try - { - ostrs01 << str01; - VERIFY( ostrs01.str() == str01 ); - } - catch(std::exception& fail) - { - VERIFY( false ); - } - - std::string_view hello_world; - std::cout << hello_world; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/char/2.cc b/gdb/unittests/basic_string_view/inserters/char/2.cc deleted file mode 100644 index 840f521..0000000 --- a/gdb/unittests/basic_string_view/inserters/char/2.cc +++ /dev/null @@ -1,91 +0,0 @@ - -// Copyright (C) 2013-2023 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/>. - -// inserters - -// NB: This file is predicated on sstreams, ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -// { dg-options "-std=gnu++17" } -// { dg-require-fileio "" } - -namespace inserters_2 { - -// testing basic_filebuf::xsputn via stress testing with large string_views -// based on a bug report libstdc++ 9 -// mode == out -static void -test05 (std::size_t size) -{ - bool test ATTRIBUTE_UNUSED = true; - - const char filename[] = "inserters_extractors-2.txt"; - const char fillc = 'f'; - std::ofstream ofs(filename); - std::string str(size, fillc); - gdb::string_view strv{str}; - - // sanity checks - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - // stress test - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - ofs.close(); - - // sanity check on the written file - std::ifstream ifs(filename); - std::size_t count = 0; - char c; - while (count <= (2 * size) + 4) - { - ifs >> c; - if (ifs.good() && c == fillc) - { - ++count; - c = '0'; - } - else - break; - } - - VERIFY( count == 2 * size ); -} - -static int -main () -{ - test05(1); - test05(1000); - test05(10000); - - return 0; -} - -} // namespace inserters_2 diff --git a/gdb/unittests/basic_string_view/inserters/char/3.cc b/gdb/unittests/basic_string_view/inserters/char/3.cc deleted file mode 100644 index 43e3ae0..0000000 --- a/gdb/unittests/basic_string_view/inserters/char/3.cc +++ /dev/null @@ -1,54 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 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/>. - -// inserters - -// NB: This file is predicated on sstreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include <string_view> -#include <sstream> -#include <iomanip> -#include <testsuite_hooks.h> - -// libstdc++/2830 -void -test09() -{ - std::string_view foo{"peace\0\0\0& love"}; - - std::ostringstream oss1; - oss1 << foo; - VERIFY( oss1.str() == foo ); - - std::ostringstream oss2; - oss2.width(20); - oss2 << foo; - VERIFY( oss2.str() != foo ); - VERIFY( oss2.str().size() == 20 ); -} - -int -main() -{ - test09(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc b/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc deleted file mode 100644 index 4b5d81d..0000000 --- a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc +++ /dev/null @@ -1,75 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 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/>. - -// class basic_istream::sentry - -#include <string_view> -#include <ostream> -#include <sstream> -#include <locale> -#include <typeinfo> -#include <testsuite_hooks.h> -#include <testsuite_character.h> - -void -test01() -{ - using namespace std; - - using __gnu_test::pod_ushort; - typedef basic_string_view<pod_ushort> string_type; - typedef basic_stringbuf<pod_ushort> stringbuf_type; - typedef basic_ostream<pod_ushort> ostream_type; - - string_type str; - stringbuf_type strbuf01; - ostream_type stream(&strbuf01); - - try - { - stream << str; - } - catch (std::bad_cast& obj) - { - // Ok, throws bad_cast because locale has no ctype facet. - } - catch (...) - { - VERIFY( false ); - } - - const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>); - stream.imbue(loc); - try - { - stream << str; - } - catch (...) - { - VERIFY( false ); - } -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc deleted file mode 100644 index 6975425..0000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc +++ /dev/null @@ -1,70 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 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/>. - -// inserters - -// NB: This file is predicated on sstreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include <string_view> -#include <stdexcept> -#include <sstream> -#include <fstream> -#include <iostream> -#include <testsuite_hooks.h> - -void -test01() -{ - typedef std::wstring_view::size_type csize_type; - typedef std::wstring_view::const_reference cref; - typedef std::wstring_view::reference ref; - - const std::wstring_view str01(L"sailing grand traverse bay\n" - L"\t\t\t from Elk Rapids to the point reminds me of miles"); - const std::wstring_view str02(L"sailing"); - const std::wstring_view str03(L"grand"); - const std::wstring_view str04(L"traverse"); - const std::wstring_view str05; - std::wstring_view str10; - - // ostream& operator<<(ostream&, const basic_string_view&) - std::wostringstream ostrs01; - try - { - ostrs01 << str01; - VERIFY( ostrs01.str() == str01 ); - } - catch(std::exception& fail) - { - VERIFY( false ); - } - - std::wstring_view hello_world; - std::wcout << hello_world; -} - -int -main() -{ - test01(); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc deleted file mode 100644 index 5cc3e93..0000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc +++ /dev/null @@ -1,91 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 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/>. - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include <string_view> -#include <string> -#include <fstream> -#include <iostream> -#include <testsuite_hooks.h> - -// testing basic_filebuf::xsputn via stress testing with large string_views -// based on a bug report libstdc++ 9 -// mode == out -void -test05(std::size_t size) -{ - bool test = true; - - const char filename[] = "inserters_extractors-2.txt"; - const wchar_t fillc = L'f'; - std::wofstream ofs(filename); - std::wstring str(size, fillc); - std::wstring_view strv(str); - - // sanity checks - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - // stress test - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - ofs << str << std::endl; - if (!ofs.good()) - test = false; - - VERIFY( str.size() == size ); - VERIFY( ofs.good() ); - - ofs.close(); - - // sanity check on the written file - std::wifstream ifs(filename); - std::size_t count = 0; - wchar_t c; - while (count <= (2 * size) + 4) - { - ifs >> c; - if (ifs.good() && c == fillc) - { - ++count; - c = '0'; - } - else - break; - } - - VERIFY( count == 2 * size ); -} - -int -main() -{ - test05(1); - test05(1000); - test05(10000); - - return 0; -} diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc deleted file mode 100644 index 5eabf46..0000000 --- a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc +++ /dev/null @@ -1,53 +0,0 @@ -// { dg-options "-std=gnu++17" } - -// Copyright (C) 2013-2023 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/>. - -// inserters - -// NB: This file is predicated on sstreams, istreams, and ostreams -// working, not to mention other major details like char_traits, and -// all of the string_view class. - -#include <string_view> -#include <sstream> -#include <iomanip> -#include <testsuite_hooks.h> - -void -test09() -{ - std::wstring_view foo{L"peace\0\0\0& love"}; - - std::wostringstream oss1; - oss1 << foo; - VERIFY( oss1.str() == foo ); - - std::wostringstream oss2; - oss2.width(20); - oss2 << foo; - VERIFY( oss2.str() != foo ); - VERIFY( oss2.str().size() == 20 ); -} - -int -main() -{ - test09(); - - return 0; -} |