1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2012-2025 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 #include <unordered_map>
21 #include <testsuite_hooks.h>
26 get_nb_bucket_elems(const std::unordered_multimap
<int, int>& us
)
29 for (std::size_t b
= 0; b
!= us
.bucket_count(); ++b
)
30 nb
+= us
.bucket_size(b
);
39 std::unordered_multimap
<int, int> umm
;
40 umm
.insert(make_pair(10, 1));
41 VERIFY( umm
.size() == 1 );
42 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
43 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
45 umm
.insert(make_pair(10, 2));
46 VERIFY( umm
.size() == 2 );
47 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
48 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
50 umm
.insert(make_pair(10, 3));
51 VERIFY( umm
.size() == 3 );
52 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
53 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
55 umm
.insert(make_pair(10, 4));
56 VERIFY( umm
.size() == 4 );
57 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
58 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
60 umm
.insert(make_pair(10, 5));
61 VERIFY( umm
.size() == 5 );
62 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
63 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
65 umm
.insert(make_pair(24, 6));
66 VERIFY( umm
.size() == 6 );
67 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
68 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
70 umm
.insert(make_pair(25, 7));
71 VERIFY( umm
.size() == 7 );
72 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
73 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
75 umm
.insert(make_pair(2, 8));
76 VERIFY( umm
.size() == 8 );
77 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
78 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
80 umm
.insert(make_pair(2, 9));
81 VERIFY( umm
.size() == 9 );
82 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
83 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
85 umm
.insert(make_pair(1, 10));
86 VERIFY( umm
.size() == 10 );
87 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
88 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );
90 umm
.insert(make_pair(10, 11));
91 VERIFY( umm
.size() == 11 );
92 VERIFY( distance(umm
.begin(), umm
.end()) - umm
.size() == 0 );
93 VERIFY( get_nb_bucket_elems(umm
) == umm
.size() );