diff options
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/unordered_set')
34 files changed, 1547 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/moveable.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/moveable.cc new file mode 100644 index 000000000..29277cfec --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 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 +// <http://www.gnu.org/licenses/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on set (via swap). If the implementation changed +// this test may begin to fail. + +#include <unordered_set> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::unordered_set<int> a,b; + a.insert(2); + b.insert(1); + b = std::move(a); + VERIFY( b.find(2) != b.end() && a.find(1) == a.end() ); + + std::unordered_set<int> c(std::move(b)); + VERIFY( c.find(2) != c.end() ); + VERIFY( b.find(2) == b.end() ); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc new file mode 100644 index 000000000..e37e5209d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc @@ -0,0 +1,34 @@ +// 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-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc new file mode 100644 index 000000000..90e5d55a4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc @@ -0,0 +1,34 @@ +// 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-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct2<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc new file mode 100644 index 000000000..e7222a9c2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc @@ -0,0 +1,34 @@ +// 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-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct3<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct4_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct4_neg.cc new file mode 100644 index 000000000..8eb030429 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct4_neg.cc @@ -0,0 +1,33 @@ +// 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-do run { xfail *-*-* } } + +#include <debug/unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc new file mode 100644 index 000000000..ab6942cca --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc @@ -0,0 +1,34 @@ +// 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-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc new file mode 100644 index 000000000..81be39da9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc @@ -0,0 +1,34 @@ +// 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-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert2<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc new file mode 100644 index 000000000..2d3b7e472 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc @@ -0,0 +1,34 @@ +// 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-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +#include <unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert3<std::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert4_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert4_neg.cc new file mode 100644 index 000000000..96d6a2a05 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert4_neg.cc @@ -0,0 +1,33 @@ +// 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-do run { xfail *-*-* } } + +#include <debug/unordered_set> +#include <debug/checks.h> + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::unordered_set<int> >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erase/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/1.cc new file mode 100644 index 000000000..8f59773d8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/1.cc @@ -0,0 +1,128 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 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/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + typedef Set::iterator iterator; + typedef Set::const_iterator const_iterator; + + Set s1; + + s1.insert("because to why"); + s1.insert("the stockholm syndrome"); + s1.insert("a cereous night"); + s1.insert("eeilo"); + s1.insert("protean"); + s1.insert("the way you are when"); + s1.insert("tillsammans"); + s1.insert("umbra/penumbra"); + s1.insert("belonging (no longer mix)"); + s1.insert("one line behind"); + VERIFY( s1.size() == 10 ); + + VERIFY( s1.erase("eeilo") == 1 ); + VERIFY( s1.size() == 9 ); + iterator it1 = s1.find("eeilo"); + VERIFY( it1 == s1.end() ); + + VERIFY( s1.erase("tillsammans") == 1 ); + VERIFY( s1.size() == 8 ); + iterator it2 = s1.find("tillsammans"); + VERIFY( it2 == s1.end() ); + + // Must work (see DR 526) + iterator it3 = s1.find("belonging (no longer mix)"); + VERIFY( it3 != s1.end() ); + VERIFY( s1.erase(*it3) == 1 ); + VERIFY( s1.size() == 7 ); + it3 = s1.find("belonging (no longer mix)"); + VERIFY( it3 == s1.end() ); + + VERIFY( !s1.erase("abra") ); + VERIFY( s1.size() == 7 ); + + VERIFY( !s1.erase("eeilo") ); + VERIFY( s1.size() == 7 ); + + VERIFY( s1.erase("because to why") == 1 ); + VERIFY( s1.size() == 6 ); + iterator it4 = s1.find("because to why"); + VERIFY( it4 == s1.end() ); + + iterator it5 = s1.find("umbra/penumbra"); + iterator it6 = s1.find("one line behind"); + VERIFY( it5 != s1.end() ); + VERIFY( it6 != s1.end() ); + + VERIFY( s1.find("the stockholm syndrome") != s1.end() ); + VERIFY( s1.find("a cereous night") != s1.end() ); + VERIFY( s1.find("the way you are when") != s1.end() ); + VERIFY( s1.find("a cereous night") != s1.end() ); + + VERIFY( s1.erase(*it5) == 1 ); + VERIFY( s1.size() == 5 ); + it5 = s1.find("umbra/penumbra"); + VERIFY( it5 == s1.end() ); + + VERIFY( s1.erase(*it6) == 1 ); + VERIFY( s1.size() == 4 ); + it6 = s1.find("one line behind"); + VERIFY( it6 == s1.end() ); + + iterator it7 = s1.begin(); + iterator it8 = it7; + ++it8; + iterator it9 = it8; + ++it9; + + VERIFY( s1.erase(*it8) == 1 ); + VERIFY( s1.size() == 3 ); + VERIFY( ++it7 == it9 ); + + iterator it10 = it9; + ++it10; + iterator it11 = it10; + + VERIFY( s1.erase(*it9) == 1 ); + VERIFY( s1.size() == 2 ); + VERIFY( ++it10 == s1.end() ); + + VERIFY( s1.erase(s1.begin()) != s1.end() ); + VERIFY( s1.size() == 1 ); + VERIFY( s1.begin() == it11 ); + + VERIFY( s1.erase(*s1.begin()) == 1 ); + VERIFY( s1.size() == 0 ); + VERIFY( s1.begin() == s1.end() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erase/24061-set.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/24061-set.cc new file mode 100644 index 000000000..b4cdde62d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/24061-set.cc @@ -0,0 +1,104 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 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/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + typedef Set::iterator iterator; + typedef Set::const_iterator const_iterator; + + Set s1; + + s1.insert("all the love in the world"); + s1.insert("you know what you are?"); + s1.insert("the collector"); + s1.insert("the hand that feeds"); + s1.insert("love is not enough"); + s1.insert("every day is exactly the same"); + s1.insert("with teeth"); + s1.insert("only"); + s1.insert("getting smaller"); + s1.insert("sunspots"); + VERIFY( s1.size() == 10 ); + + iterator it1 = s1.begin(); + ++it1; + iterator it2 = it1; + ++it2; + iterator it3 = s1.erase(it1); + VERIFY( s1.size() == 9 ); + VERIFY( it3 == it2 ); + VERIFY( *it3 == *it2 ); + + iterator it4 = s1.begin(); + ++it4; + ++it4; + ++it4; + iterator it5 = it4; + ++it5; + ++it5; + iterator it6 = s1.erase(it4, it5); + VERIFY( s1.size() == 7 ); + VERIFY( it6 == it5 ); + VERIFY( *it6 == *it5 ); + + const_iterator it7 = s1.begin(); + ++it7; + ++it7; + ++it7; + const_iterator it8 = it7; + ++it8; + const_iterator it9 = s1.erase(it7); + VERIFY( s1.size() == 6 ); + VERIFY( it9 == it8 ); + VERIFY( *it9 == *it8 ); + + const_iterator it10 = s1.begin(); + ++it10; + const_iterator it11 = it10; + ++it11; + ++it11; + ++it11; + ++it11; + const_iterator it12 = s1.erase(it10, it11); + VERIFY( s1.size() == 2 ); + VERIFY( it12 == it11 ); + VERIFY( *it12 == *it11 ); + VERIFY( ++it12 == s1.end() ); + + iterator it13 = s1.erase(s1.begin(), s1.end()); + VERIFY( s1.size() == 0 ); + VERIFY( it13 == s1.end() ); + VERIFY( it13 == s1.begin() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc new file mode 100644 index 000000000..148646042 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 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 } +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator==(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::unordered_set<X>& s, X x) +{ + std::unordered_set<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/26132.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/26132.cc new file mode 100644 index 000000000..afa1ddd5d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/26132.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-08-13 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/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +// libstdc++/26132 +void test01() +{ + bool test __attribute__((unused)) = true; + + for (float lf = 1.0; lf < 101.0; lf *= 10.0) + for (int size = 1; size <= 6561; size *= 3) + { + std::unordered_set<int> us1; + typedef std::unordered_set<int>::size_type size_type; + + us1.max_load_factor(10.0); + + for (int i = 0; i < size; ++i) + us1.insert(i); + + us1.max_load_factor(lf); + + for (int i = 1; i <= 6561; i *= 81) + { + const size_type n = size * 81 / i; + us1.rehash(n); + VERIFY( us1.bucket_count() > us1.size() / us1.max_load_factor() ); + VERIFY( us1.bucket_count() >= n ); + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/dr1189.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/dr1189.cc new file mode 100644 index 000000000..e7047dbdd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/dr1189.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-10 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/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +// DR 1189. Awkward interface for changing the number of buckets +// in an unordered associative container +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_set<int> s1; + s1.reserve(10); + VERIFY( s1.bucket_count() >= 10 ); + + s1.reserve(100); + VERIFY( s1.bucket_count() >= 100 ); + + std::unordered_set<int> s2(100); + VERIFY( s2.bucket_count() >= 100 ); + + s2.reserve(1000); + VERIFY( s2.bucket_count() >= 1000 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc new file mode 100644 index 000000000..adcd8a440 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2008, 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/>. +// + +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + unordered_set<int> m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42 }); + VERIFY(m.size() == 4); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 1); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/insert/24061-set.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/24061-set.cc new file mode 100644 index 000000000..54add3512 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/24061-set.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-10 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/>. + +#include <unordered_set> +#include <string> +#include <testsuite_hooks.h> + +// libstdc++/24061 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + typedef Set::iterator iterator; + typedef Set::const_iterator const_iterator; + + Set s1; + + iterator it1 = s1.insert(s1.begin(), "all the love in the world"); + VERIFY( s1.size() == 1 ); + VERIFY( *it1 == "all the love in the world" ); + + const_iterator cit1(it1); + const_iterator cit2 = s1.insert(cit1, "you know what you are?"); + VERIFY( s1.size() == 2 ); + VERIFY( cit2 != cit1 ); + VERIFY( *cit2 == "you know what you are?" ); + + iterator it2 = s1.insert(it1, "all the love in the world"); + VERIFY( s1.size() == 2 ); + VERIFY( it2 == it1 ); + VERIFY( *it2 == "all the love in the world" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_range.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_range.cc new file mode 100644 index 000000000..86bd326bd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_range.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// 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/>. + +// range insert + +#include <string> +#include <iterator> +#include <algorithm> +#include <unordered_set> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void test01() +{ + typedef std::unordered_set<std::string> Set; + Set s; + VERIFY(s.empty()); + + const int N = 10; + const std::string A[N] = { "red", "green", "blue", "violet", "cyan", + "magenta", "yellow", "orange", "pink", "gray" }; + + s.insert(A+0, A+N); + VERIFY(s.size() == static_cast<unsigned int>(N)); + VERIFY(std::distance(s.begin(), s.end()) == N); + + for (int i = 0; i < N; ++i) { + std::string str = A[i]; + Set::iterator it = std::find(s.begin(), s.end(), str); + VERIFY(it != s.end()); + } +} + +void test02() +{ + typedef std::unordered_set<int> Set; + Set s; + VERIFY(s.empty()); + + const int N = 8; + const int A[N] = { 3, 7, 4, 8, 2, 4, 6, 7 }; + + s.insert(A+0, A+N); + VERIFY(s.size() == 6); + VERIFY(std::distance(s.begin(), s.end()) == 6); + + VERIFY(std::count(s.begin(), s.end(), 2) == 1); + VERIFY(std::count(s.begin(), s.end(), 3) == 1); + VERIFY(std::count(s.begin(), s.end(), 4) == 1); + VERIFY(std::count(s.begin(), s.end(), 6) == 1); + VERIFY(std::count(s.begin(), s.end(), 7) == 1); + VERIFY(std::count(s.begin(), s.end(), 8) == 1); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single.cc new file mode 100644 index 000000000..d1288ce42 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// 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/>. + +// Single-element insert + +#include <string> +#include <iterator> +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + Set s; + VERIFY(s.empty()); + + std::pair<Set::iterator, bool> p = s.insert("abcde"); + VERIFY(p.second); + VERIFY(s.size() == 1); + VERIFY(std::distance(s.begin(), s.end()) == 1); + VERIFY(p.first == s.begin()); + VERIFY(*p.first == "abcde"); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::unordered_set<std::string> Set; + Set s; + VERIFY(s.empty()); + + std::pair<Set::iterator, bool> p1 = s.insert("abcde"); + std::pair<Set::iterator, bool> p2 = s.insert("abcde"); + VERIFY(p1.second); + VERIFY(!p2.second); + VERIFY(s.size() == 1); + VERIFY(p1.first == p2.first); + VERIFY(*p1.first == "abcde"); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single_move.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single_move.cc new file mode 100644 index 000000000..0b9ad173b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single_move.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-10-27 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/>. + +// Single-element insert + +#include <iterator> +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + std::pair<Set::iterator, bool> p = s.insert(rvalstruct(1)); + VERIFY( p.second ); + VERIFY( s.size() == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( p.first == s.begin() ); + VERIFY( (*p.first).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::unordered_set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + std::pair<Set::iterator, bool> p1 = s.insert(rvalstruct(2)); + std::pair<Set::iterator, bool> p2 = s.insert(rvalstruct(2)); + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( s.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( (*p1.first).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc new file mode 100644 index 000000000..63e726d04 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 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/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_set<int> us1, us2; + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(2); + us2.insert(2); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(3); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us2.insert(3); + VERIFY( (us1 == us2) ); + VERIFY( !(us1 != us2) ); + + us2.clear(); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.clear(); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(2); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.insert(2); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(3); + us2.insert(4); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.insert(4); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us2.insert(3); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(4); + us2.insert(4); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + const std::unordered_set<int> cus1(us1), cus2(us2); + VERIFY( cus1 == cus2 ); + VERIFY( !(cus1 != cus2) ); + VERIFY( cus1 == us2 ); + VERIFY( !(us1 != cus2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc new file mode 100644 index 000000000..5b16f0b3c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/operators/52309.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012 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_set> + +// libstdc++/52309 +struct value {}; +struct hash { std::size_t operator()(const value&) const; }; +bool operator==(value const&, value const&); +std::unordered_set<value, hash> set; +bool z = (set == set); diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc new file mode 100644 index 000000000..2bb738afd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 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/>. + +// 24.6.5, range access [iterator.range] + +#include <unordered_set> + +void +test01() +{ + std::unordered_set<int> us{1, 2, 3}; + std::begin(us); + std::end(us); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/citerators.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/citerators.cc new file mode 100644 index 000000000..ce7f79fd6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_set<int> test_type; + __gnu_test::citerator<test_type> test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/cliterators.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/cliterators.cc new file mode 100644 index 000000000..8abef8c1c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/cliterators.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-06-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008, 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/>. + +#include <unordered_set> +#include <testsuite_containers.h> + +int main() +{ + typedef std::unordered_set<int> test_type; + typedef typename test_type::value_type value_type; + value_type v(1); + __gnu_test::forward_members_unordered<test_type> test(v); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_container.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_container.cc new file mode 100644 index 000000000..f2405fa4b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_container.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 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 +// <http://www.gnu.org/licenses/>. + +#include <debug/unordered_set> + +using namespace __gnu_debug; + +template class unordered_set<int>; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_mode.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_mode.cc new file mode 100644 index 000000000..206b70437 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/debug_mode.cc @@ -0,0 +1,30 @@ +// NB: This issue affected only debug-mode. + +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2008, 2009, 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/>. + +#include <unordered_set> + +//PR libstdc++/35922 +int main() +{ + std::unordered_set<int> s; +} + diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/basic.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/basic.cc new file mode 100644 index 000000000..6d0e3f52b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/basic.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 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/>. + +#include <unordered_set> +#include <exception/safety.h> + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_set<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::basic_safety<test_type> test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/generation_prohibited.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..0841cf013 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 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/>. + +#include <unordered_set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_set<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::generation_prohibited<test_type> test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/propagation_consistent.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..ab1d74d03 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik <benjamin@redhat.com> + +// Copyright (C) 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/>. + +#include <unordered_set> +#include <exception/safety.h> + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type; + typedef std::hash<value_type> hash_type; + typedef std::equal_to<value_type> pred_type; + typedef std::unordered_set<value_type, hash_type, pred_type, allocator_type> test_type; + __gnu_test::propagation_consistent<test_type> test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..10d0bf566 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/1.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +template class std::unordered_set<int>; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..e22760460 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/2.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 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/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::NonDefaultConstructible inst_type; +typedef __gnu_test::NonDefaultConstructible_hash hash_type; +template class std::unordered_set<inst_type, hash_type>; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..7d84ffd7f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/3.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 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 +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> + +using namespace std; +template class unordered_set<int, hash<int>, equal_to<int>, allocator<char>>; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..3f619b71c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/explicit_instantiation/4.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 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/>. + +// This file tests explicit instantiation of library containers + +#include <unordered_set> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +typedef __gnu_test::OverloadedAddress inst_type; +typedef __gnu_test::OverloadedAddress_hash hash_type; + +// libstdc++/41792 +template class std::unordered_set<inst_type, hash_type>; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/typedefs.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/typedefs.cc new file mode 100644 index 000000000..86983e5a6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 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/>. + +#include <testsuite_containers.h> +#include <unordered_set> + +// Check container for required typedefs. +__gnu_test::types<std::unordered_set<int> > t; |