summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/23_containers/unordered_set
diff options
context:
space:
mode:
authorfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-05 21:16:07 +0000
committerfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-05 21:16:07 +0000
commite2c4a09ac84838edd25dfe60c95218f30d346a8e (patch)
tree152a853df6a0b5caf0d08a72377394d5d134c646 /libstdc++-v3/testsuite/23_containers/unordered_set
parent0446c24409c82d7399e9a9d00553d4d902ace22d (diff)
downloadgcc-e2c4a09ac84838edd25dfe60c95218f30d346a8e.tar.gz
2015-07-05 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable.h (_Hashtable<>::__rehash_policy): Do not rehash container. * testsuite/23_containers/unordered_set/max_load_factor/robustness.cc: Adapt. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225436 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/unordered_set')
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc
index a72829e0d43..59782286e22 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/max_load_factor/robustness.cc
@@ -32,41 +32,47 @@ void test01()
int val = 0;
for (; val != 100; ++val)
{
- VERIFY( us.insert(val).second) ;
+ VERIFY( us.insert(val).second );
VERIFY( us.load_factor() <= us.max_load_factor() );
}
float cur_max_load_factor = us.max_load_factor();
int counter = 0;
std::size_t thrown_exceptions = 0;
+
+ // Reduce max load factor.
+ us.max_load_factor(us.max_load_factor() / 2);
+
+ // At this point load factor is higher than max_load_factor because we can't
+ // rehash in max_load_factor call.
+ VERIFY( us.load_factor() > us.max_load_factor() );
+
while (true)
{
__gnu_cxx::limit_condition::set_limit(counter++);
bool do_break = false;
try
{
- us.max_load_factor(.5f);
+ size_t nbkts = us.bucket_count();
+ // Check that unordered_set will still be correctly resized when
+ // needed.
+ VERIFY( us.insert(val++).second );
+
+ VERIFY( us.bucket_count() != nbkts );
+ VERIFY( us.load_factor() <= us.max_load_factor() );
do_break = true;
}
catch (const __gnu_cxx::forced_error&)
{
- VERIFY( us.max_load_factor() == cur_max_load_factor );
+ // max load factor doesn't change.
+ VERIFY( us.max_load_factor() == .5f );
++thrown_exceptions;
}
- // Lets check that unordered_set will still be correctly resized
- // when needed
- __gnu_cxx::limit_condition::set_limit(nl_size_t::max());
- for (;;)
- {
- VERIFY( us.load_factor() <= us.max_load_factor() );
- size_t nbkts = us.bucket_count();
- VERIFY( us.insert(val++).second );
- if (us.bucket_count() != nbkts)
- break;
- }
+
if (do_break)
break;
}
+
VERIFY( thrown_exceptions > 0 );
}