2012-05-01 François Dumont <fdumont@gcc.gnu.org>
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_multiset / insert / 53115.cc
bloba23eacb753fceaf63523a75b76ba4003f2c7ac59
1 // { dg-options "-std=gnu++11" }
2 //
3 // Copyright (C) 2012 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.
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_set>
21 #include <testsuite_hooks.h>
23 namespace
25 std::size_t
26 get_nb_bucket_elems(const std::unordered_multiset<int>& us)
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;
35 void test01()
37 using namespace std;
38 bool test __attribute__((unused)) = true;
40 std::unordered_multiset<int> mms;
41 mms.insert(10);
42 VERIFY( mms.size() == 1 );
43 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
44 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
46 mms.insert(10);
47 VERIFY( mms.size() == 2 );
48 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
49 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
51 mms.insert(10);
52 VERIFY( mms.size() == 3 );
53 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
54 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
56 mms.insert(10);
57 VERIFY( mms.size() == 4 );
58 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
59 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
61 mms.insert(10);
62 VERIFY( mms.size() == 5 );
63 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
64 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
66 mms.insert(24);
67 VERIFY( mms.size() == 6 );
68 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
69 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
71 mms.insert(25);
72 VERIFY( mms.size() == 7 );
73 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
74 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
76 mms.insert(2);
77 VERIFY( mms.size() == 8 );
78 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
79 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
81 mms.insert(2);
82 VERIFY( mms.size() == 9 );
83 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
84 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
86 mms.insert(1);
87 VERIFY( mms.size() == 10 );
88 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
89 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
91 mms.insert(10);
92 VERIFY( mms.size() == 11 );
93 VERIFY( std::distance(mms.begin(), mms.end()) == mms.size() );
94 VERIFY( get_nb_bucket_elems(mms) == mms.size() );
97 int main()
99 test01();
100 return 0;