]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/multimap/modifiers/merge.cc
1 // Copyright (C) 2016-2023 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-do run { target c++17 } }
22 #include <testsuite_hooks.h>
24 using test_type
= std::multimap
<int, int>;
29 const test_type c0
{ {1, 10}, {1, 11}, {2, 20}, {2, 21}, {3, 30}, {3, 31} };
30 test_type c1
= c0
, c2
= c0
;
34 VERIFY( c1
.count(i
.first
) == (2 * c0
.count(i
.first
)) );
39 c1
.merge(std::move(c2
));
47 const test_type c0
{ {1, 10}, {1, 11}, {2, 20}, {2, 21}, {3, 30}, {3, 31} };
49 std::multimap
<int, int, std::less
<>> c2( c0
.begin(), c0
.end() );
52 VERIFY( c1
.size() == (2 * c0
.size()) );
54 VERIFY( c1
.count(i
.first
) == (2 * c0
.count(i
.first
)) );
58 c2
.insert( c0
.begin(), c0
.end() );
59 c1
.merge(std::move(c2
));
67 const test_type c0
{ {1, 10}, {1, 11}, {2, 20}, {2, 21}, {3, 30}, {3, 31} };
69 std::multimap
<int, int, std::greater
<>> c2( c0
.begin(), c0
.end() );
72 VERIFY( c1
.size() == (2 * c0
.size()) );
74 VERIFY( c1
.count(i
.first
) == (2 * c0
.count(i
.first
)) );
78 c2
.insert( c0
.begin(), c0
.end() );
79 c1
.merge(std::move(c2
));
87 const test_type c0
{ {1, 10}, {1, 11}, {2, 20}, {2, 21}, {3, 30}, {3, 31} };
89 std::map
<int, int, std::greater
<>> c2( c0
.begin(), c0
.end() );
92 VERIFY( c1
.size() == (1.5 * c0
.size()) );
94 VERIFY( c1
.count(i
.first
) == (1.5 * c0
.count(i
.first
)) );
98 c2
.insert( c0
.begin(), c0
.end() );
99 c1
.merge(std::move(c2
));
100 VERIFY( c1
.size() == (0.5 * c0
.size()) );
101 VERIFY( c2
.empty() );