1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2011-2013 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 <ext/throw_allocator.h>
23 #include <testsuite_hooks.h>
27 bool test
__attribute__((unused
)) = true;
29 typedef std::numeric_limits
<std::size_t> nl_size_t
;
30 std::unordered_set
<int, std::hash
<int>, std::equal_to
<int>,
31 __gnu_cxx::throw_allocator_limit
<int> > us
;
33 for (; val
!= 100; ++val
)
35 VERIFY( us
.insert(val
).second
) ;
36 VERIFY( us
.load_factor() <= us
.max_load_factor() );
39 float cur_max_load_factor
= us
.max_load_factor();
41 std::size_t thrown_exceptions
= 0;
44 __gnu_cxx::limit_condition::set_limit(counter
++);
45 bool do_break
= false;
48 us
.max_load_factor(.5f
);
51 catch (const __gnu_cxx::forced_error
&)
53 VERIFY( us
.max_load_factor() == cur_max_load_factor
);
56 // Lets check that unordered_set will still be correctly resized
58 __gnu_cxx::limit_condition::set_limit(nl_size_t::max());
61 VERIFY( us
.load_factor() <= us
.max_load_factor() );
62 size_t nbkts
= us
.bucket_count();
63 VERIFY( us
.insert(val
++).second
);
64 if (us
.bucket_count() != nbkts
)
70 VERIFY( thrown_exceptions
> 0 );