diff options
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite')
17 files changed, 346 insertions, 25 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/12.cc b/gcc-4.9/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/12.cc new file mode 100644 index 000000000..a0dda5f63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/12.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2014 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/>. + +#include <string> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + std::string s; + getline(std::istringstream("First line\nSecond line\n"), s); + VERIFY( s == "First line" ); + getline(std::istringstream("Third line\nFourth line\n"), s, 'r'); + VERIFY( s == "Thi" ); +} + +int +main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/12.cc b/gcc-4.9/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/12.cc new file mode 100644 index 000000000..db20c0293 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/12.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2014 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/>. + +#include <string> +#include <sstream> +#include <testsuite_hooks.h> + +void +test01() +{ + std::wstring s; + getline(std::wistringstream(L"First line\nSecond line\n"), s); + VERIFY( s == L"First line" ); + getline(std::wistringstream(L"Third line\nFourth line\n"), s, L'r'); + VERIFY( s == L"Thi" ); +} + +int +main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/61667.cc b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/61667.cc new file mode 100644 index 000000000..cb4ad8ecb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/61667.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2011-2014 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/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + std::unordered_map<int, int> um(20); + + std::size_t bkt_count = um.bucket_count(); + + um.max_load_factor(um.max_load_factor()); + + VERIFY( um.bucket_count() >= bkt_count ); + + um.max_load_factor(um.max_load_factor() * 2.f); + + VERIFY( um.bucket_count() >= bkt_count ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc b/gcc-4.9/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc new file mode 100644 index 000000000..11d553910 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +#include <random> + +std::mt19937 urng; + +std::__detail::_Adaptor<std::mt19937, unsigned long> aurng(urng); + +auto x = std::generate_canonical<std::size_t, + std::numeric_limits<std::size_t>::digits>(urng); + +// { dg-error "static assertion failed: template argument not a floating point type" "" { target *-*-* } 167 } + +// { dg-error "static assertion failed: template argument not a floating point type" "" { target *-*-* } 3466 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/forced_unwind.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/forced_unwind.cc new file mode 100644 index 000000000..7b0a49280 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/async/forced_unwind.cc @@ -0,0 +1,45 @@ +// { dg-do run { target *-*-linux* *-*-gnu* } } +// { dg-options " -std=gnu++11 -pthread" { target *-*-linux* *-*-gnu* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2014 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/>. + +// Test (non-standard) handling of __forced_unwind exception. + +#include <future> +#include <stdexcept> +#include <pthread.h> +#include <testsuite_hooks.h> + +void f() { pthread_exit(nullptr); } + +int main() +{ + auto fut = std::async(std::launch::async, f); + try + { + fut.get(); + throw std::logic_error("Unreachable"); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::broken_promise ); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/forced_unwind.cc b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/forced_unwind.cc new file mode 100644 index 000000000..235ab178f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/30_threads/packaged_task/forced_unwind.cc @@ -0,0 +1,48 @@ +// { dg-do run { target *-*-linux* *-*-gnu* } } +// { dg-options " -std=gnu++11 -pthread" { target *-*-linux* *-*-gnu* } } +// { dg-require-cstdint "" } +// { dg-require-gthreads "" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2014 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/>. + +// Test (non-standard) handling of __forced_unwind exception. + +#include <future> +#include <stdexcept> +#include <pthread.h> +#include <testsuite_hooks.h> + +void f() { pthread_exit(nullptr); } + +int main() +{ + std::packaged_task<void()> p(f); + auto fut = p.get_future(); + std::thread t(std::move(p)); + try + { + fut.get(); + throw std::logic_error("Unreachable"); + } + catch (const std::future_error& e) + { + VERIFY( e.code() == std::future_errc::broken_promise ); + } + t.join(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/1.cc index c879cc7e0..a443b0ac7 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/1.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/char/1.cc @@ -33,7 +33,7 @@ test01() // basic_string_view() const std::experimental::string_view str00{}; VERIFY( str00.length() == 0 ); - VERIFY( str00.data() != nullptr ); + VERIFY( str00.data() == nullptr ); // basic_string_view(const char*) const char str_lit01[] = "rodeo beach, marin"; @@ -54,11 +54,6 @@ test01() VERIFY( str05.length() == len_lit01 ); VERIFY( str05.data() == str_lit01 ); - // basic_string_view(const char* s, std::size_t l) - std::experimental::string_view str06{nullptr, len_lit01}; - VERIFY( str06.length() == 0 ); - VERIFY( str06.data() != nullptr ); - // basic_string_view(basic_string& s) std::string istr07(10, 'z'); std::experimental::string_view str07{istr07}; diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc index 12db72f28..9ba9b84a1 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/cons/wchar_t/1.cc @@ -33,7 +33,7 @@ test01() // basic_string_view() const std::experimental::wstring_view str00{}; VERIFY( str00.length() == 0 ); - VERIFY( str00.data() != nullptr ); + VERIFY( str00.data() == nullptr ); // basic_string_view(const char*) const wchar_t str_lit01[] = L"rodeo beach, marin"; @@ -54,11 +54,6 @@ test01() VERIFY( str05.length() == len_lit01 ); VERIFY( str05.data() == str_lit01 ); - // basic_string_view(const wchar_t* s, std::size_t l) - std::experimental::wstring_view str06{nullptr, len_lit01}; - VERIFY( str06.length() == 0 ); - VERIFY( str06.data() != nullptr ); - // basic_string_view(basic_string& s) std::wstring istr07(10, L'z'); std::experimental::wstring_view str07{istr07}; diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/char/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/char/1.cc index 25b2af133..d0f3e8d69 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/char/1.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/char/1.cc @@ -1,6 +1,6 @@ // { dg-options "-std=gnu++1y" } -// Copyright (C) 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 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 @@ -20,7 +20,6 @@ // basic_string_view::copy #include <experimental/string_view> -#include <stdexcept> #include <testsuite_hooks.h> bool diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/wchar_t/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/wchar_t/1.cc index 0348e1f98..bf3f14b14 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/wchar_t/1.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/copy/wchar_t/1.cc @@ -1,6 +1,6 @@ // { dg-options "-std=gnu++1y" } -// Copyright (C) 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 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 @@ -20,7 +20,6 @@ // basic_string_view::copy #include <experimental/string_view> -#include <stdexcept> #include <testsuite_hooks.h> bool diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/char/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/char/1.cc index be75de917..a34492606 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/char/1.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/char/1.cc @@ -1,6 +1,6 @@ // { dg-options "-std=gnu++1y" } -// Copyright (C) 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 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 @@ -29,10 +29,9 @@ test01() std::experimental::string_view empty; - // data() for size == 0 is non-NULL. VERIFY( empty.size() == 0 ); const std::experimental::string_view::value_type* p = empty.data(); - VERIFY( p ); + VERIFY( p == nullptr ); return 0; } diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/wchar_t/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/wchar_t/1.cc index 5e00b00b6..41d2d1411 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/wchar_t/1.cc +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/data/wchar_t/1.cc @@ -1,6 +1,6 @@ // { dg-options "-std=gnu++1y" } -// Copyright (C) 2013 Free Software Foundation, Inc. +// Copyright (C) 2013-2014 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 @@ -29,10 +29,9 @@ test01() std::experimental::wstring_view empty; - // data() for size == 0 is non-NULL. VERIFY( empty.size() == 0 ); const std::experimental::wstring_view::value_type* p = empty.data(); - VERIFY( p ); + VERIFY( p == nullptr ); return 0; } diff --git a/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/to_string/1.cc b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/to_string/1.cc new file mode 100644 index 000000000..c0a5734c6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/experimental/string_view/operations/to_string/1.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2014 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/>. + +// basic_string_view::to_string + +#include <experimental/string_view> +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +bool +test01() +{ + bool test [[gnu::unused]] = true; + + const char str_lit[] = "123456789A"; + const std::experimental::string_view sv(str_lit); + char buffer[4] = { 0 }; + + auto s1 = sv.to_string(); + VERIFY( s1 == str_lit ); + using test_alloc = __gnu_test::tracker_allocator<char>; + auto s2 = sv.to_string( test_alloc{} ); + static_assert( std::is_same<decltype(s2)::allocator_type, test_alloc>::value, + "to_string() uses custom allocator" ); + VERIFY( std::equal(s1.begin(), s1.end(), s2.begin(), s2.end()) ); + auto s3 = static_cast<std::string>(sv); + VERIFY( s3 == s1 ); + + return test; +} + +int +main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/pr60037.cc b/gcc-4.9/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/pr60037.cc new file mode 100644 index 000000000..d3088a6ec --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/ext/random/hypergeometric_distribution/pr60037.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++11 -O0" } +// { dg-require-cstdint "" } +// { dg-require-cmath "" } + +#include <ext/random> +#include <functional> + +void +hyperplot(unsigned int N, unsigned int K, unsigned int n) +{ + std::mt19937 re; // the default engine + __gnu_cxx::hypergeometric_distribution<> hd(N, K, n); + auto gen = std::bind(hd, re); + gen(); +} + +int +main() +{ + hyperplot(15, 3, 2); + hyperplot(500, 50, 30); + hyperplot(100, 20, 5); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/ext/rope/61946.cc b/gcc-4.9/libstdc++-v3/testsuite/ext/rope/61946.cc new file mode 100644 index 000000000..ba73b4856 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/ext/rope/61946.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2014 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-do compile } + +#include <ext/rope> + +struct empty_char_prod : __gnu_cxx::char_producer<char> +{ + virtual void operator()(size_t, size_t, char*) {} +}; + +int main () +{ + empty_char_prod* ecp = new empty_char_prod; + __gnu_cxx::crope excrope( ecp, 10L, true ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/lib/gdb-test.exp b/gcc-4.9/libstdc++-v3/testsuite/lib/gdb-test.exp index 1a72a4430..2169f26d2 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/lib/gdb-test.exp +++ b/gcc-4.9/libstdc++-v3/testsuite/lib/gdb-test.exp @@ -91,7 +91,7 @@ proc gdb-test { marker {selector {}} } { } } - set do_whatis_tests [gdb_batch_check "python print gdb.type_printers" \ + set do_whatis_tests [gdb_batch_check "python print(gdb.type_printers)" \ "\\\[\\\]"] if {!$do_whatis_tests} { send_log "skipping 'whatis' tests - gdb too old" @@ -252,6 +252,6 @@ proc gdb_batch_check {command pattern} { # but not earlier versions. # Return 1 if the version is ok, 0 otherwise. proc gdb_version_check {} { - return [gdb_batch_check "python print gdb.lookup_global_symbol" \ + return [gdb_batch_check "python print(gdb.lookup_global_symbol)" \ "<built-in function lookup_global_symbol>"] } diff --git a/gcc-4.9/libstdc++-v3/testsuite/util/testsuite_iterators.h b/gcc-4.9/libstdc++-v3/testsuite/util/testsuite_iterators.h index c6905811c..6cf18b400 100644 --- a/gcc-4.9/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/gcc-4.9/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -518,7 +518,7 @@ namespace __gnu_test * It takes two pointers representing a range and presents them as * a container of iterators. */ - template <class T, template<class T> class ItType> + template <class T, template<class TT> class ItType> struct test_container { typename ItType<T>::ContainerType bounds; |