summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/tr1/6_containers/unordered_set
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/tr1/6_containers/unordered_set
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/tr1/6_containers/unordered_set')
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23053.cc38
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23465.cc63
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26127.cc38
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26132.cc57
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc38
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/erase/1.cc129
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/erase/24061-set.cc104
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/find/set1.cc65
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/24061-set.cc57
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/set_range.cc80
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/set_single.cc66
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc36
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_neg.cc36
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_null_neg.cc28
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterators_default_constructor.cc31
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/typedefs.cc45
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/1.cc152
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/2.cc181
18 files changed, 1244 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23053.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23053.cc
new file mode 100644
index 000000000..b828c2799
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23053.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+
+// Copyright (C) 2005, 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/>.
+
+// 6.3 Unordered associative containers
+
+#include <tr1/unordered_set>
+
+// libstdc++/23053
+void test01()
+{
+ std::tr1::unordered_set<int> s;
+
+ const std::tr1::unordered_set<int> &s_ref = s;
+
+ s_ref.find(27);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23465.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23465.cc
new file mode 100644
index 000000000..19bc2ff5b
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/23465.cc
@@ -0,0 +1,63 @@
+// Copyright (C) 2005, 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/>.
+
+// 6.3 Unordered associative containers
+
+#include <tr1/unordered_set>
+#include <testsuite_hooks.h>
+
+// libstdc++/23465
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ for (float lf = 0.1; lf < 101.0; lf *= 10.0)
+ for (int size = 1; size <= 6561; size *= 3)
+ {
+ std::tr1::unordered_set<int> us1, us2;
+ typedef std::tr1::unordered_set<int>::local_iterator local_iterator;
+ typedef std::tr1::unordered_set<int>::size_type size_type;
+
+ us1.max_load_factor(lf);
+
+ for (int i = 0; i < size; ++i)
+ us1.insert(i);
+
+ us2 = us1;
+
+ VERIFY( us2.size() == us1.size() );
+ VERIFY( us2.bucket_count() == us1.bucket_count() );
+
+ for (size_type b = 0; b < us1.bucket_count(); ++b)
+ {
+ size_type cnt = 0;
+ for (local_iterator it1 = us1.begin(b), it2 = us2.begin(b);
+ it1 != us1.end(b) && it2 != us2.end(b); ++it1, ++it2)
+ {
+ VERIFY( *it1 == *it2 );
+ ++cnt;
+ }
+ VERIFY( cnt == us1.bucket_size(b) );
+ }
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26127.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26127.cc
new file mode 100644
index 000000000..435418608
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26127.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+
+// Copyright (C) 2006, 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/>.
+
+// 6.3 Unordered associative containers
+
+#include <tr1/unordered_set>
+
+// libstdc++/26127
+void test01()
+{
+ std::tr1::unordered_set<int> s;
+
+ s.bucket(42);
+ s.key_eq();
+ s.max_load_factor();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26132.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26132.cc
new file mode 100644
index 000000000..8fd846410
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/26132.cc
@@ -0,0 +1,57 @@
+// 2006-02-22 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006, 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/>.
+
+// 6.3 Unordered associative containers
+
+#include <tr1/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::tr1::unordered_set<int> us1;
+ typedef std::tr1::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/tr1/6_containers/unordered_set/capacity/29134-set.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc
new file mode 100644
index 000000000..63abcd41e
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc
@@ -0,0 +1,38 @@
+// Copyright (C) 2006, 2007, 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/>.
+
+// 6.3.4.3 Class template unordered_set
+
+#include <tr1/unordered_set>
+#include <testsuite_hooks.h>
+
+// libstdc++/29134
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::tr1::unordered_set<int> us;
+
+ VERIFY( (us.max_size() == std::allocator<std::tr1::__detail::_Hash_node<
+ int, false> >().max_size()) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/erase/1.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/erase/1.cc
new file mode 100644
index 000000000..5eebef314
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/erase/1.cc
@@ -0,0 +1,129 @@
+// 2007-02-22 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/>.
+
+// 6.3.4.3 Class template unordered_set
+
+#include <tr1/unordered_set>
+#include <string>
+#include <testsuite_hooks.h>
+
+// In the occasion of libstdc++/25896
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::tr1::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/tr1/6_containers/unordered_set/erase/24061-set.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/erase/24061-set.cc
new file mode 100644
index 000000000..8ff3cad55
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/erase/24061-set.cc
@@ -0,0 +1,104 @@
+// 2005-10-08 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 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/>.
+
+// 6.3.4.3 Class template unordered_set
+
+#include <tr1/unordered_set>
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/24061
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::tr1::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/tr1/6_containers/unordered_set/find/set1.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/find/set1.cc
new file mode 100644
index 000000000..67dd20546
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/find/set1.cc
@@ -0,0 +1,65 @@
+// { dg-do run }
+
+// 2005-2-18 Matt Austern <austern@apple.com>
+//
+// Copyright (C) 2005, 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/>.
+
+// 6.3.4.3 unordered_set
+// find, equal_range, count
+
+#include <string>
+#include <iterator>
+#include <algorithm>
+#include <tr1/unordered_set>
+#include "testsuite_hooks.h"
+
+bool test __attribute__((unused)) = true;
+
+void test01()
+{
+ typedef std::tr1::unordered_set<std::string> Set;
+ Set s;
+ VERIFY(s.empty());
+
+ std::pair<Set::iterator, bool> tmp = s.insert("grape");
+ Set::iterator i = tmp.first;
+
+ Set::iterator i2 = s.find("grape");
+ VERIFY(i2 != s.end());
+ VERIFY(i2 == i);
+ VERIFY(*i2 == "grape");
+
+ std::pair<Set::iterator, Set::iterator> p = s.equal_range("grape");
+ VERIFY(p.first == i2);
+ VERIFY(std::distance(p.first, p.second) == 1);
+
+ Set::iterator i3 = s.find("lime");
+ VERIFY(i3 == s.end());
+
+ std::pair<Set::iterator, Set::iterator> p2 = s.equal_range("lime");
+ VERIFY(p2.first == p2.second);
+
+ VERIFY(s.count("grape") == 1);
+ VERIFY(s.count("lime") == 0);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/24061-set.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/24061-set.cc
new file mode 100644
index 000000000..f5cb09938
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/24061-set.cc
@@ -0,0 +1,57 @@
+// 2005-10-08 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 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/>.
+
+// 6.3.4.3 Class template unordered_set
+
+#include <tr1/unordered_set>
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/24061
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::tr1::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/tr1/6_containers/unordered_set/insert/set_range.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/set_range.cc
new file mode 100644
index 000000000..9d7bcbf8a
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/set_range.cc
@@ -0,0 +1,80 @@
+// { dg-do run }
+
+// 2005-2-17 Matt Austern <austern@apple.com>
+//
+// Copyright (C) 2005, 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/>.
+
+// 6.3.4.3 unordered_set
+// range insert
+
+#include <string>
+#include <iterator>
+#include <algorithm>
+#include <tr1/unordered_set>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+void test01()
+{
+ typedef std::tr1::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::tr1::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/tr1/6_containers/unordered_set/insert/set_single.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/set_single.cc
new file mode 100644
index 000000000..d298b9e7a
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/insert/set_single.cc
@@ -0,0 +1,66 @@
+// { dg-do run }
+
+// 2005-2-17 Matt Austern <austern@apple.com>
+//
+// Copyright (C) 2005, 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/>.
+
+// 6.3.4.3 unordered_set
+// Single-element insert
+
+#include <string>
+#include <iterator>
+#include <tr1/unordered_set>
+#include "testsuite_hooks.h"
+
+bool test __attribute__((unused)) = true;
+
+void test01()
+{
+ typedef std::tr1::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()
+{
+ typedef std::tr1::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/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc
new file mode 100644
index 000000000..6c6ec2e17
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/explicit_instantiation.cc
@@ -0,0 +1,36 @@
+// { dg-do compile }
+
+// 2005-02-17 Matt Austern <austern@apple.com>
+//
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 6.3.4.3 unordered_set
+
+#include <tr1/unordered_set>
+
+using namespace std::tr1;
+using std::equal_to;
+using std::allocator;
+
+template class unordered_set<int>;
+template class unordered_set<float, hash<float>, equal_to<float>,
+ allocator<float> >;
+template class unordered_set<int, hash<int>, equal_to<int>,
+ allocator<char> >;
+template class __unordered_set<float, hash<float>, equal_to<float>,
+ allocator<float>, true>;
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_neg.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_neg.cc
new file mode 100644
index 000000000..b06ef15eb
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_neg.cc
@@ -0,0 +1,36 @@
+// 2005-10-02 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 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-do compile }
+
+#include <tr1/unordered_set>
+
+void test01()
+{
+ typedef std::tr1::unordered_set<int> Set;
+
+ Set s;
+
+ Set::const_iterator cit = s.begin();
+ *cit = 0; // { dg-error "read-only" }
+
+ Set::const_local_iterator clit = s.begin(0);
+ *clit = 0; // { dg-error "read-only" }
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_null_neg.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_null_neg.cc
new file mode 100644
index 000000000..a0747ec47
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterator_null_neg.cc
@@ -0,0 +1,28 @@
+// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 2009, 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 }
+
+// libstdc++/23781
+#include <tr1/unordered_set>
+#include <cstddef>
+
+std::tr1::unordered_set<int>::iterator it4 = NULL; // { dg-error "conversion" }
+std::tr1::unordered_set<int>::const_iterator cit4 = NULL; // { dg-error "conversion" }
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterators_default_constructor.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterators_default_constructor.cc
new file mode 100644
index 000000000..ecada3dd2
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/iterators_default_constructor.cc
@@ -0,0 +1,31 @@
+// { dg-do compile }
+
+// Copyright (C) 2006, 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/>.
+
+// 6.3 Unordered associative containers
+
+#include <tr1/unordered_set>
+
+void
+test01()
+{
+ std::tr1::unordered_set<int>::iterator it;
+ std::tr1::unordered_set<int>::const_iterator cit;
+ std::tr1::unordered_set<int>::local_iterator lit;
+ std::tr1::unordered_set<int>::const_local_iterator clit;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/typedefs.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/typedefs.cc
new file mode 100644
index 000000000..a1f4a31f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/requirements/typedefs.cc
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// 2008-08-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// 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/>.
+
+// 6.3.4.3 unordered_set
+
+#include <tr1/unordered_set>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::tr1::unordered_set<int> test_type;
+
+ typedef test_type::key_type key_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::hasher hasher;
+ typedef test_type::key_equal key_equal;
+ typedef test_type::allocator_type allocator_type;
+ typedef test_type::pointer pointer;
+ typedef test_type::const_pointer const_pointer;
+ typedef test_type::reference reference;
+ typedef test_type::const_reference const_reference;
+ typedef test_type::size_type size_type;
+ typedef test_type::difference_type difference_type;
+ typedef test_type::iterator iterator;
+ typedef test_type::const_iterator const_iterator;
+ typedef test_type::local_iterator local_iterator;
+ typedef test_type::const_local_iterator const_local_iterator;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/1.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/1.cc
new file mode 100644
index 000000000..d14be65de
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/1.cc
@@ -0,0 +1,152 @@
+// 2005-12-20 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 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/>.
+
+// 6.3.4.3 unordered_set::swap
+
+#include <tr1/unordered_set>
+#include <set>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+// uneq_allocator as a non-empty allocator.
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std::tr1;
+ using std::equal_to;
+ using std::set;
+
+ typedef __gnu_test::uneq_allocator<char> my_alloc;
+ typedef unordered_set<char, hash<char>, equal_to<char>, my_alloc> my_uset;
+
+ const char title01[] = "Rivers of sand";
+ const char title02[] = "Concret PH";
+ const char title03[] = "Sonatas and Interludes for Prepared Piano";
+ const char title04[] = "never as tired as when i'm waking up";
+
+ const size_t N1 = sizeof(title01);
+ const size_t N2 = sizeof(title02);
+ const size_t N3 = sizeof(title03);
+ const size_t N4 = sizeof(title04);
+
+ typedef set<char> my_set;
+ const my_set set01_ref(title01, title01 + N1);
+ const my_set set02_ref(title02, title02 + N2);
+ const my_set set03_ref(title03, title03 + N3);
+ const my_set set04_ref(title04, title04 + N4);
+
+ my_uset::size_type size01, size02;
+
+ my_alloc alloc01(1);
+
+ my_uset uset01(10, hash<char>(), equal_to<char>(), alloc01);
+ size01 = uset01.size();
+ my_uset uset02(10, hash<char>(), equal_to<char>(), alloc01);
+ size02 = uset02.size();
+
+ uset01.swap(uset02);
+ VERIFY( uset01.size() == size02 );
+ VERIFY( uset01.empty() );
+ VERIFY( uset02.size() == size01 );
+ VERIFY( uset02.empty() );
+
+ my_uset uset03(10, hash<char>(), equal_to<char>(), alloc01);
+ size01 = uset03.size();
+ my_uset uset04(set02_ref.begin(), set02_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset04.size();
+
+ uset03.swap(uset04);
+ VERIFY( uset03.size() == size02 );
+ VERIFY( my_set(uset03.begin(), uset03.end()) == set02_ref );
+ VERIFY( uset04.size() == size01 );
+ VERIFY( uset04.empty() );
+
+ my_uset uset05(set01_ref.begin(), set01_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset05.size();
+ my_uset uset06(set02_ref.begin(), set02_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset06.size();
+
+ uset05.swap(uset06);
+ VERIFY( uset05.size() == size02 );
+ VERIFY( my_set(uset05.begin(), uset05.end()) == set02_ref );
+ VERIFY( uset06.size() == size01 );
+ VERIFY( my_set(uset06.begin(), uset06.end()) == set01_ref );
+
+ my_uset uset07(set01_ref.begin(), set01_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset07.size();
+ my_uset uset08(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset08.size();
+
+ uset07.swap(uset08);
+ VERIFY( uset07.size() == size02 );
+ VERIFY( my_set(uset07.begin(), uset07.end()) == set03_ref );
+ VERIFY( uset08.size() == size01 );
+ VERIFY( my_set(uset08.begin(), uset08.end()) == set01_ref );
+
+ my_uset uset09(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset09.size();
+ my_uset uset10(set04_ref.begin(), set04_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset10.size();
+
+ uset09.swap(uset10);
+ VERIFY( uset09.size() == size02 );
+ VERIFY( my_set(uset09.begin(), uset09.end()) == set04_ref );
+ VERIFY( uset10.size() == size01 );
+ VERIFY( my_set(uset10.begin(), uset10.end()) == set03_ref );
+
+ my_uset uset11(set04_ref.begin(), set04_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset11.size();
+ my_uset uset12(set01_ref.begin(), set01_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset12.size();
+
+ uset11.swap(uset12);
+ VERIFY( uset11.size() == size02 );
+ VERIFY( my_set(uset11.begin(), uset11.end()) == set01_ref );
+ VERIFY( uset12.size() == size01 );
+ VERIFY( my_set(uset12.begin(), uset12.end()) == set04_ref );
+
+ my_uset uset13(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset13.size();
+ my_uset uset14(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset14.size();
+
+ uset13.swap(uset14);
+ VERIFY( uset13.size() == size02 );
+ VERIFY( my_set(uset13.begin(), uset13.end()) == set03_ref );
+ VERIFY( uset14.size() == size01 );
+ VERIFY( my_set(uset14.begin(), uset14.end()) == set03_ref );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/2.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/2.cc
new file mode 100644
index 000000000..93477f615
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered_set/swap/2.cc
@@ -0,0 +1,181 @@
+// 2005-12-20 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 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/>.
+
+// 6.3.4.3 unordered_set::swap
+
+#include <tr1/unordered_set>
+#include <set>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+// uneq_allocator, two different personalities.
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std::tr1;
+ using std::equal_to;
+ using std::set;
+
+ typedef __gnu_test::uneq_allocator<char> my_alloc;
+ typedef unordered_set<char, hash<char>, equal_to<char>, my_alloc> my_uset;
+
+ const char title01[] = "Rivers of sand";
+ const char title02[] = "Concret PH";
+ const char title03[] = "Sonatas and Interludes for Prepared Piano";
+ const char title04[] = "never as tired as when i'm waking up";
+
+ const size_t N1 = sizeof(title01);
+ const size_t N2 = sizeof(title02);
+ const size_t N3 = sizeof(title03);
+ const size_t N4 = sizeof(title04);
+
+ typedef set<char> my_set;
+ const my_set set01_ref(title01, title01 + N1);
+ const my_set set02_ref(title02, title02 + N2);
+ const my_set set03_ref(title03, title03 + N3);
+ const my_set set04_ref(title04, title04 + N4);
+
+ my_uset::size_type size01, size02;
+
+ my_alloc alloc01(1), alloc02(2);
+ int personality01, personality02;
+
+ my_uset uset01(10, hash<char>(), equal_to<char>(), alloc01);
+ size01 = uset01.size();
+ personality01 = uset01.get_allocator().get_personality();
+ my_uset uset02(10, hash<char>(), equal_to<char>(), alloc02);
+ size02 = uset02.size();
+ personality02 = uset02.get_allocator().get_personality();
+
+ uset01.swap(uset02);
+ VERIFY( uset01.size() == size02 );
+ VERIFY( uset01.empty() );
+ VERIFY( uset02.size() == size01 );
+ VERIFY( uset02.empty() );
+ VERIFY( uset01.get_allocator().get_personality() == personality02 );
+ VERIFY( uset02.get_allocator().get_personality() == personality01 );
+
+ my_uset uset03(10, hash<char>(), equal_to<char>(), alloc02);
+ size01 = uset03.size();
+ personality01 = uset03.get_allocator().get_personality();
+ my_uset uset04(set02_ref.begin(), set02_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset04.size();
+ personality02 = uset04.get_allocator().get_personality();
+
+ uset03.swap(uset04);
+ VERIFY( uset03.size() == size02 );
+ VERIFY( my_set(uset03.begin(), uset03.end()) == set02_ref );
+ VERIFY( uset04.size() == size01 );
+ VERIFY( uset04.empty() );
+ VERIFY( uset03.get_allocator().get_personality() == personality02 );
+ VERIFY( uset04.get_allocator().get_personality() == personality01 );
+
+ my_uset uset05(set01_ref.begin(), set01_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset05.size();
+ personality01 = uset05.get_allocator().get_personality();
+ my_uset uset06(set02_ref.begin(), set02_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc02);
+ size02 = uset06.size();
+ personality02 = uset06.get_allocator().get_personality();
+
+ uset05.swap(uset06);
+ VERIFY( uset05.size() == size02 );
+ VERIFY( my_set(uset05.begin(), uset05.end()) == set02_ref );
+ VERIFY( uset06.size() == size01 );
+ VERIFY( my_set(uset06.begin(), uset06.end()) == set01_ref );
+ VERIFY( uset05.get_allocator().get_personality() == personality02 );
+ VERIFY( uset06.get_allocator().get_personality() == personality01 );
+
+ my_uset uset07(set01_ref.begin(), set01_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc02);
+ size01 = uset07.size();
+ personality01 = uset07.get_allocator().get_personality();
+ my_uset uset08(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset08.size();
+ personality02 = uset08.get_allocator().get_personality();
+
+ uset07.swap(uset08);
+ VERIFY( uset07.size() == size02 );
+ VERIFY( my_set(uset07.begin(), uset07.end()) == set03_ref );
+ VERIFY( uset08.size() == size01 );
+ VERIFY( my_set(uset08.begin(), uset08.end()) == set01_ref );
+ VERIFY( uset07.get_allocator().get_personality() == personality02 );
+ VERIFY( uset08.get_allocator().get_personality() == personality01 );
+
+ my_uset uset09(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset09.size();
+ personality01 = uset09.get_allocator().get_personality();
+ my_uset uset10(set04_ref.begin(), set04_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc02);
+ size02 = uset10.size();
+ personality02 = uset10.get_allocator().get_personality();
+
+ uset09.swap(uset10);
+ VERIFY( uset09.size() == size02 );
+ VERIFY( my_set(uset09.begin(), uset09.end()) == set04_ref );
+ VERIFY( uset10.size() == size01 );
+ VERIFY( my_set(uset10.begin(), uset10.end()) == set03_ref );
+ VERIFY( uset09.get_allocator().get_personality() == personality02 );
+ VERIFY( uset10.get_allocator().get_personality() == personality01 );
+
+ my_uset uset11(set04_ref.begin(), set04_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc02);
+ size01 = uset11.size();
+ personality01 = uset11.get_allocator().get_personality();
+ my_uset uset12(set01_ref.begin(), set01_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size02 = uset12.size();
+ personality02 = uset12.get_allocator().get_personality();
+
+ uset11.swap(uset12);
+ VERIFY( uset11.size() == size02 );
+ VERIFY( my_set(uset11.begin(), uset11.end()) == set01_ref );
+ VERIFY( uset12.size() == size01 );
+ VERIFY( my_set(uset12.begin(), uset12.end()) == set04_ref );
+ VERIFY( uset11.get_allocator().get_personality() == personality02 );
+ VERIFY( uset12.get_allocator().get_personality() == personality01 );
+
+ my_uset uset13(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc01);
+ size01 = uset13.size();
+ personality01 = uset13.get_allocator().get_personality();
+ my_uset uset14(set03_ref.begin(), set03_ref.end(), 10, hash<char>(),
+ equal_to<char>(), alloc02);
+ size02 = uset14.size();
+ personality02 = uset14.get_allocator().get_personality();
+
+ uset13.swap(uset14);
+ VERIFY( uset13.size() == size02 );
+ VERIFY( my_set(uset13.begin(), uset13.end()) == set03_ref );
+ VERIFY( uset14.size() == size01 );
+ VERIFY( my_set(uset14.begin(), uset14.end()) == set03_ref );
+ VERIFY( uset13.get_allocator().get_personality() == personality02 );
+ VERIFY( uset14.get_allocator().get_personality() == personality01 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}