1 // { dg-options "-std=gnu++11" }
2 //
3 // Copyright (C) 2012-2016 Free Software Foundation, Inc.
4 //
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)
9 // any later version.
10 //
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.
15 //
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/>.
19 
20 #include <unordered_set>
21 #include <testsuite_hooks.h>
22 
23 namespace
24 {
25   std::size_t
get_nb_bucket_elems(const std::unordered_multiset<int> & us)26   get_nb_bucket_elems(const std::unordered_multiset<int>& us)
27   {
28     std::size_t nb = 0;
29     for (std::size_t b = 0; b != us.bucket_count(); ++b)
30       nb += us.bucket_size(b);
31     return nb;
32   }
33 }
34 
test01()35 void test01()
36 {
37   using namespace std;
38   bool test __attribute__((unused)) = true;
39 
40   std::unordered_multiset<int> mms;
41   mms.insert(10);
42   VERIFY( mms.size() == 1 );
43   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
44   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
45 
46   mms.insert(10);
47   VERIFY( mms.size() == 2 );
48   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
49   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
50 
51   mms.insert(10);
52   VERIFY( mms.size() == 3 );
53   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
54   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
55 
56   mms.insert(10);
57   VERIFY( mms.size() == 4 );
58   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
59   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
60 
61   mms.insert(10);
62   VERIFY( mms.size() == 5 );
63   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
64   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
65 
66   mms.insert(24);
67   VERIFY( mms.size() == 6 );
68   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
69   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
70 
71   mms.insert(25);
72   VERIFY( mms.size() == 7 );
73   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
74   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
75 
76   mms.insert(2);
77   VERIFY( mms.size() == 8 );
78   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
79   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
80 
81   mms.insert(2);
82   VERIFY( mms.size() == 9 );
83   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
84   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
85 
86   mms.insert(1);
87   VERIFY( mms.size() == 10 );
88   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
89   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
90 
91   mms.insert(10);
92   VERIFY( mms.size() == 11 );
93   VERIFY( distance(mms.begin(), mms.end()) - mms.size() == 0 );
94   VERIFY( get_nb_bucket_elems(mms) == mms.size() );
95 }
96 
main()97 int main()
98 {
99   test01();
100   return 0;
101 }
102