]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/set/modifiers/merge.cc
60313d4752ae45cf104edd2011300a21d439c73e
1 // Copyright (C) 2016-2021 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-std=gnu++17" }
19 // { dg-do run { target c++17 } }
23 #include <testsuite_hooks.h>
25 using test_type
= std::set
<int>;
30 const test_type c0
{ 1, 2, 3 };
31 test_type c1
= c0
, c2
= c0
;
41 c2
.merge(std::move(c1
));
49 const test_type c0
{ 1, 2, 3 };
51 std::set
<int, std::less
<>> c2( c0
.begin(), c0
.end() );
54 VERIFY( std::equal(c2
.begin(), c2
.end(), c0
.begin(), c0
.end()) );
61 c2
.merge(std::move(c1
));
63 VERIFY( std::equal(c2
.begin(), c2
.end(), c0
.begin(), c0
.end()) );
69 const test_type c0
{ 1, 2, 3 };
71 std::set
<int, std::greater
<>> c2( c0
.begin(), c0
.end() );
74 VERIFY( std::equal(c2
.rbegin(), c2
.rend(), c0
.begin(), c0
.end()) );
83 VERIFY( std::equal(c2
.rbegin(), c2
.rend(), c0
.begin(), c0
.end()) );
85 c1
.merge(std::move(c2
));
93 const test_type c0
{ 1, 2, 3 };
95 std::multiset
<int, std::greater
<>> c2( c0
.begin(), c0
.end() );
98 VERIFY( std::equal(c2
.rbegin(), c2
.rend(), c0
.begin(), c0
.end()) );
103 VERIFY( c2
.empty() );
106 VERIFY( c1
.empty() );
107 VERIFY( std::equal(c2
.rbegin(), c2
.rend(), c0
.begin(), c0
.end()) );
111 VERIFY( c1
.empty() );
112 VERIFY( c2
.size() == (2 * c0
.size()) );
113 VERIFY( std::is_sorted(c2
.begin(), c2
.end(), c2
.value_comp()) );
117 VERIFY( std::equal(c2
.rbegin(), c2
.rend(), c0
.begin(), c0
.end()) );
119 c1
.merge(std::move(c2
));
121 VERIFY( std::equal(c2
.rbegin(), c2
.rend(), c0
.begin(), c0
.end()) );
124 c1
.merge(std::move(c2
));
126 VERIFY( c2
.empty() );