1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2011 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_set>
22 #include <testsuite_hooks.h>
27 get_nb_bucket_elems(const std::unordered_multiset<std::string>& us)
30 for (std::size_t b = 0; b != us.bucket_count(); ++b)
31 nb += us.bucket_size(b);
38 bool test __attribute__((unused)) = true;
40 typedef std::unordered_multiset<std::string> Mset;
41 typedef Mset::iterator iterator;
42 typedef Mset::const_iterator const_iterator;
58 VERIFY( ms1.size() == 12 );
59 VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
60 VERIFY( distance(ms1.begin(), ms1.end()) == ms1.size() );
62 VERIFY( ms1.erase(ms1.begin()) != ms1.end() );
63 VERIFY( ms1.size() == 11 );
64 VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
65 VERIFY( distance(ms1.begin(), ms1.end()) == ms1.size() );
67 auto it = ms1.begin();
69 VERIFY( ms1.erase(ms1.begin(), it) != ms1.end() );
70 VERIFY( ms1.size() == 9 );
71 VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
72 VERIFY( distance(ms1.begin(), ms1.end()) == ms1.size() );
74 VERIFY( ms1.erase(*(ms1.begin())) == 3 );
75 VERIFY( ms1.size() == 6 );
76 VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
77 VERIFY( distance(ms1.begin(), ms1.end()) == ms1.size() );
79 VERIFY( ms1.erase(ms1.begin(), ms1.end()) == ms1.end() );
80 VERIFY( ms1.empty() );
81 VERIFY( get_nb_bucket_elems(ms1) == ms1.size() );
82 VERIFY( distance(ms1.begin(), ms1.end()) == ms1.size() );