diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/23_containers/set/modifiers | |
download | cbb-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/23_containers/set/modifiers')
9 files changed, 756 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/16728.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/16728.cc new file mode 100644 index 000000000..28376a353 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/16728.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2004, 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/>. + + +/* + * The goal with this application is to compare the performance + * between different std::allocator implementations. The results are + * influenced by the underlying allocator in the "C" library, malloc. + */ + +#include <set> +#include <sstream> + +using namespace std; + +typedef int test_type; + +// This can take extremely long on simulators, timing out the test. +// { dg-options "-DITERATIONS=10" { target simulator } } +#ifndef ITERATIONS +#define ITERATIONS 10000 +#endif + +// The number of iterations to be performed. +int iterations = ITERATIONS; + +// The number of values to insert in the container, 32 will cause 5 +// (re)allocations to be performed (sizes 4, 8, 16, 32 and 64) +// This means that all allocations are within _MAX_BYTES = 128 as +// defined in stl_alloc.h for __pool_alloc. Whether or not this +// value is relevant in "the real world" or not I don't know and +// should probably be investigated in more detail. +int insert_values = 128; + +template<typename TestType> + struct value_type : public pair<TestType, TestType> + { + value_type() : pair<TestType, TestType>(0, 0) { } + + inline value_type operator++() { return ++this->first, *this; } + inline operator TestType() const { return this->first; } + }; + +template<typename Container> + void + do_loop() + { + Container obj; + int test_iterations = 0; + value_type<test_type> test_value; + while (test_iterations < iterations) + { + for (int j = 0; j < insert_values; ++j) + obj.insert(obj.end(), ++test_value); + ++test_iterations; + } + } + +template<typename Container> + void + test_container(Container, bool run_threaded = false) + { + do_loop<Container>(); + std::ostringstream comment; + if (run_threaded) + comment << "4-way threaded iterations: " << iterations*4 << '\t'; + else + comment << "iterations: " << iterations << '\t'; + } + +// http://gcc.gnu.org/ml/libstdc++/2001-05/msg00105.html +// http://gcc.gnu.org/ml/libstdc++/2003-05/msg00231.html +int main(void) +{ + typedef less<test_type> compare_type; + test_container(set<test_type, compare_type>()); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/17948.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/17948.cc new file mode 100644 index 000000000..baee1fe8a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/17948.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2004, 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/>. + +#include <set> +#include <testsuite_hooks.h> + +// libstdc++/17948 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef set<int>::size_type size_type; + + set<int> s; + + s.insert(2); + s.insert(3); + + size_type x = s.erase(3); + + VERIFY( s.size() == 1 ); + VERIFY( x == 1 ); +} + +int main () +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc new file mode 100644 index 000000000..4fb296a95 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/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 <set> + +struct X +{ + template<typename T> + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::set<X>& s, X x) +{ + std::set<X>::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/1.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/1.cc new file mode 100644 index 000000000..0b2dd3e2a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/1.cc @@ -0,0 +1,83 @@ +// 2005-01-17 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/>. +// + +#include <set> +#include <testsuite_hooks.h> + +// A few tests for insert with hint, in the occasion of libstdc++/19422 +// and libstdc++/19433. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + set<int> s0, s1; + set<int>::iterator iter1; + + s0.insert(1); + s1.insert(s1.end(), 1); + VERIFY( s0 == s1 ); + + s0.insert(3); + s1.insert(s1.begin(), 3); + VERIFY( s0 == s1 ); + + s0.insert(4); + iter1 = s1.insert(s1.end(), 4); + VERIFY( s0 == s1 ); + + s0.insert(6); + s1.insert(iter1, 6); + VERIFY( s0 == s1 ); + + s0.insert(2); + s1.insert(s1.begin(), 2); + VERIFY( s0 == s1 ); + + s0.insert(7); + s1.insert(s1.end(), 7); + VERIFY( s0 == s1 ); + + s0.insert(5); + s1.insert(s1.find(4), 5); + VERIFY( s0 == s1 ); + + s0.insert(0); + s1.insert(s1.end(), 0); + VERIFY( s0 == s1 ); + + s0.insert(8); + s1.insert(s1.find(3), 8); + VERIFY( s0 == s1 ); + + s0.insert(9); + s1.insert(s1.end(), 9); + VERIFY( s0 == s1 ); + + s0.insert(10); + s1.insert(s1.begin(), 10); + VERIFY( s0 == s1 ); +} + +int main () +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/2.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/2.cc new file mode 100644 index 000000000..31159262b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/2.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-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 <iterator> +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::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::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/set/modifiers/insert/3.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/3.cc new file mode 100644 index 000000000..03e0d9d6c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/insert/3.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-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 <iterator> +#include <set> +#include <testsuite_hooks.h> +#include <testsuite_rvalref.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator p = s.insert(s.begin(), rvalstruct(1)); + VERIFY( s.size() == 1 ); + VERIFY( std::distance(s.begin(), s.end()) == 1 ); + VERIFY( p == s.begin() ); + VERIFY( (*p).val == 1 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::set<rvalstruct> Set; + Set s; + VERIFY( s.empty() ); + + Set::iterator p1 = s.insert(s.begin(), rvalstruct(2)); + Set::iterator p2 = s.insert(p1, rvalstruct(2)); + VERIFY( s.size() == 1 ); + VERIFY( p1 == p2 ); + VERIFY( (*p1).val == 2 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc new file mode 100644 index 000000000..789185f8f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004, 2005, 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/>. + +#include <set> +#include <testsuite_hooks.h> + +struct T { int i; }; + +// T must be LessThanComparable to pass concept-checks +bool operator<(T l, T r) { return l.i < r.i; } + +int swap_calls; + +namespace std +{ + template<> + void + set<T>::swap(set<T>&) + { ++swap_calls; } +} + +// Should use set specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::set<T> A; + std::set<T> B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use set specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + set<T> A; + set<T> B; + swap_calls = 0; + swap(A, B); + VERIFY(1 == swap_calls); +} + +// See c++/13658 for background info. +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/2.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/2.cc new file mode 100644 index 000000000..8899b6dae --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/2.cc @@ -0,0 +1,137 @@ +// 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/>. + +// 23.3.3 set::swap + +#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; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef set<char, less<char>, my_alloc> my_set; + + 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); + + const set<char> set01_ref(title01, title01 + N1); + const set<char> set02_ref(title02, title02 + N2); + const set<char> set03_ref(title03, title03 + N3); + const set<char> set04_ref(title04, title04 + N4); + + my_set::size_type size01, size02; + + my_alloc alloc01(1); + + my_set set01(less<char>(), alloc01); + size01 = set01.size(); + my_set set02(less<char>(), alloc01); + size02 = set02.size(); + + set01.swap(set02); + VERIFY( set01.size() == size02 ); + VERIFY( set01.empty() ); + VERIFY( set02.size() == size01 ); + VERIFY( set02.empty() ); + + my_set set03(less<char>(), alloc01); + size01 = set03.size(); + my_set set04(title02, title02 + N2, less<char>(), alloc01); + size02 = set04.size(); + + set03.swap(set04); + VERIFY( set03.size() == size02 ); + VERIFY( equal(set03.begin(), set03.end(), set02_ref.begin()) ); + VERIFY( set04.size() == size01 ); + VERIFY( set04.empty() ); + + my_set set05(title01, title01 + N1, less<char>(), alloc01); + size01 = set05.size(); + my_set set06(title02, title02 + N2, less<char>(), alloc01); + size02 = set06.size(); + + set05.swap(set06); + VERIFY( set05.size() == size02 ); + VERIFY( equal(set05.begin(), set05.end(), set02_ref.begin()) ); + VERIFY( set06.size() == size01 ); + VERIFY( equal(set06.begin(), set06.end(), set01_ref.begin()) ); + + my_set set07(title01, title01 + N1, less<char>(), alloc01); + size01 = set07.size(); + my_set set08(title03, title03 + N3, less<char>(), alloc01); + size02 = set08.size(); + + set07.swap(set08); + VERIFY( set07.size() == size02 ); + VERIFY( equal(set07.begin(), set07.end(), set03_ref.begin()) ); + VERIFY( set08.size() == size01 ); + VERIFY( equal(set08.begin(), set08.end(), set01_ref.begin()) ); + + my_set set09(title03, title03 + N3, less<char>(), alloc01); + size01 = set09.size(); + my_set set10(title04, title04 + N4, less<char>(), alloc01); + size02 = set10.size(); + + set09.swap(set10); + VERIFY( set09.size() == size02 ); + VERIFY( equal(set09.begin(), set09.end(), set04_ref.begin()) ); + VERIFY( set10.size() == size01 ); + VERIFY( equal(set10.begin(), set10.end(), set03_ref.begin()) ); + + my_set set11(title04, title04 + N4, less<char>(), alloc01); + size01 = set11.size(); + my_set set12(title01, title01 + N1, less<char>(), alloc01); + size02 = set12.size(); + + set11.swap(set12); + VERIFY( set11.size() == size02 ); + VERIFY( equal(set11.begin(), set11.end(), set01_ref.begin()) ); + VERIFY( set12.size() == size01 ); + VERIFY( equal(set12.begin(), set12.end(), set04_ref.begin()) ); + + my_set set13(title03, title03 + N3, less<char>(), alloc01); + size01 = set13.size(); + my_set set14(title03, title03 + N3, less<char>(), alloc01); + size02 = set14.size(); + + set13.swap(set14); + VERIFY( set13.size() == size02 ); + VERIFY( equal(set13.begin(), set13.end(), set03_ref.begin()) ); + VERIFY( set14.size() == size01 ); + VERIFY( equal(set14.begin(), set14.end(), set03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/3.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/3.cc new file mode 100644 index 000000000..5f192293d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/3.cc @@ -0,0 +1,166 @@ +// 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/>. + +// 23.3.3 set::swap + +#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; + + typedef __gnu_test::uneq_allocator<char> my_alloc; + typedef set<char, less<char>, my_alloc> my_set; + + 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); + + const set<char> set01_ref(title01, title01 + N1); + const set<char> set02_ref(title02, title02 + N2); + const set<char> set03_ref(title03, title03 + N3); + const set<char> set04_ref(title04, title04 + N4); + + my_set::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_set set01(less<char>(), alloc01); + size01 = set01.size(); + personality01 = set01.get_allocator().get_personality(); + my_set set02(less<char>(), alloc02); + size02 = set02.size(); + personality02 = set02.get_allocator().get_personality(); + + set01.swap(set02); + VERIFY( set01.size() == size02 ); + VERIFY( set01.empty() ); + VERIFY( set02.size() == size01 ); + VERIFY( set02.empty() ); + VERIFY( set01.get_allocator().get_personality() == personality02 ); + VERIFY( set02.get_allocator().get_personality() == personality01 ); + + my_set set03(less<char>(), alloc02); + size01 = set03.size(); + personality01 = set03.get_allocator().get_personality(); + my_set set04(title02, title02 + N2, less<char>(), alloc01); + size02 = set04.size(); + personality02 = set04.get_allocator().get_personality(); + + set03.swap(set04); + VERIFY( set03.size() == size02 ); + VERIFY( equal(set03.begin(), set03.end(), set02_ref.begin()) ); + VERIFY( set04.size() == size01 ); + VERIFY( set04.empty() ); + VERIFY( set03.get_allocator().get_personality() == personality02 ); + VERIFY( set04.get_allocator().get_personality() == personality01 ); + + my_set set05(title01, title01 + N1, less<char>(), alloc01); + size01 = set05.size(); + personality01 = set05.get_allocator().get_personality(); + my_set set06(title02, title02 + N2, less<char>(), alloc02); + size02 = set06.size(); + personality02 = set06.get_allocator().get_personality(); + + set05.swap(set06); + VERIFY( set05.size() == size02 ); + VERIFY( equal(set05.begin(), set05.end(), set02_ref.begin()) ); + VERIFY( set06.size() == size01 ); + VERIFY( equal(set06.begin(), set06.end(), set01_ref.begin()) ); + VERIFY( set05.get_allocator().get_personality() == personality02 ); + VERIFY( set06.get_allocator().get_personality() == personality01 ); + + my_set set07(title01, title01 + N1, less<char>(), alloc02); + size01 = set07.size(); + personality01 = set07.get_allocator().get_personality(); + my_set set08(title03, title03 + N3, less<char>(), alloc01); + size02 = set08.size(); + personality02 = set08.get_allocator().get_personality(); + + set07.swap(set08); + VERIFY( set07.size() == size02 ); + VERIFY( equal(set07.begin(), set07.end(), set03_ref.begin()) ); + VERIFY( set08.size() == size01 ); + VERIFY( equal(set08.begin(), set08.end(), set01_ref.begin()) ); + VERIFY( set07.get_allocator().get_personality() == personality02 ); + VERIFY( set08.get_allocator().get_personality() == personality01 ); + + my_set set09(title03, title03 + N3, less<char>(), alloc01); + size01 = set09.size(); + personality01 = set09.get_allocator().get_personality(); + my_set set10(title04, title04 + N4, less<char>(), alloc02); + size02 = set10.size(); + personality02 = set10.get_allocator().get_personality(); + + set09.swap(set10); + VERIFY( set09.size() == size02 ); + VERIFY( equal(set09.begin(), set09.end(), set04_ref.begin()) ); + VERIFY( set10.size() == size01 ); + VERIFY( equal(set10.begin(), set10.end(), set03_ref.begin()) ); + VERIFY( set09.get_allocator().get_personality() == personality02 ); + VERIFY( set10.get_allocator().get_personality() == personality01 ); + + my_set set11(title04, title04 + N4, less<char>(), alloc02); + size01 = set11.size(); + personality01 = set11.get_allocator().get_personality(); + my_set set12(title01, title01 + N1, less<char>(), alloc01); + size02 = set12.size(); + personality02 = set12.get_allocator().get_personality(); + + set11.swap(set12); + VERIFY( set11.size() == size02 ); + VERIFY( equal(set11.begin(), set11.end(), set01_ref.begin()) ); + VERIFY( set12.size() == size01 ); + VERIFY( equal(set12.begin(), set12.end(), set04_ref.begin()) ); + VERIFY( set11.get_allocator().get_personality() == personality02 ); + VERIFY( set12.get_allocator().get_personality() == personality01 ); + + my_set set13(title03, title03 + N3, less<char>(), alloc01); + size01 = set13.size(); + personality01 = set13.get_allocator().get_personality(); + my_set set14(title03, title03 + N3, less<char>(), alloc02); + size02 = set14.size(); + personality02 = set14.get_allocator().get_personality(); + + set13.swap(set14); + VERIFY( set13.size() == size02 ); + VERIFY( equal(set13.begin(), set13.end(), set03_ref.begin()) ); + VERIFY( set14.size() == size01 ); + VERIFY( equal(set14.begin(), set14.end(), set03_ref.begin()) ); + VERIFY( set13.get_allocator().get_personality() == personality02 ); + VERIFY( set14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} |