LWG#2156 loosened the requirements on unordered containers 'rehash' calls. Add tests to make sure we meet these requirements. Since we met the stricter ones, no code change needed to meet the looser ones.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@253223 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,6 +22,12 @@
|
||||
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void rehash_postcondition(const C& c, size_t n)
|
||||
{
|
||||
assert(c.bucket_count() >= c.size() / c.max_load_factor() && c.bucket_count() >= n);
|
||||
}
|
||||
|
||||
template <class C>
|
||||
void test(const C& c)
|
||||
{
|
||||
@@ -77,13 +83,16 @@ int main()
|
||||
test(c);
|
||||
assert(c.bucket_count() >= 7);
|
||||
c.rehash(3);
|
||||
rehash_postcondition(c, 3);
|
||||
assert(c.bucket_count() == 7);
|
||||
test(c);
|
||||
c.max_load_factor(2);
|
||||
c.rehash(3);
|
||||
rehash_postcondition(c, 3);
|
||||
assert(c.bucket_count() == 3);
|
||||
test(c);
|
||||
c.rehash(31);
|
||||
rehash_postcondition(c, 31);
|
||||
assert(c.bucket_count() == 31);
|
||||
test(c);
|
||||
}
|
||||
@@ -105,13 +114,16 @@ int main()
|
||||
test(c);
|
||||
assert(c.bucket_count() >= 7);
|
||||
c.rehash(3);
|
||||
rehash_postcondition(c, 3);
|
||||
assert(c.bucket_count() == 7);
|
||||
test(c);
|
||||
c.max_load_factor(2);
|
||||
c.rehash(3);
|
||||
rehash_postcondition(c, 3);
|
||||
assert(c.bucket_count() == 3);
|
||||
test(c);
|
||||
c.rehash(31);
|
||||
rehash_postcondition(c, 31);
|
||||
assert(c.bucket_count() == 31);
|
||||
test(c);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user