diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2015-11-16 16:42:16 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2015-11-16 16:42:16 +0000 |
commit | a9197737f97ec8a07f992bba986abb72c7eef1ea (patch) | |
tree | 03333bc65c7bd5296d90681284c55c12974ed026 /libcxx/test/std | |
parent | a770379524abd814c410cb63812b27f681dc9f1f (diff) | |
download | bcm5719-llvm-a9197737f97ec8a07f992bba986abb72c7eef1ea.tar.gz bcm5719-llvm-a9197737f97ec8a07f992bba986abb72c7eef1ea.zip |
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.
llvm-svn: 253223
Diffstat (limited to 'libcxx/test/std')
4 files changed, 48 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/unord/unord.map/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.map/rehash.pass.cpp index 84ece235551..e1a882c69ff 100644 --- a/libcxx/test/std/containers/unord/unord.map/rehash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/rehash.pass.cpp @@ -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) { assert(c.size() == 4); @@ -49,13 +55,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); 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); } @@ -77,13 +86,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); 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); } diff --git a/libcxx/test/std/containers/unord/unord.multimap/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/rehash.pass.cpp index 1d99208596c..d36dc42e262 100644 --- a/libcxx/test/std/containers/unord/unord.multimap/rehash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/rehash.pass.cpp @@ -23,6 +23,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) { assert(c.size() == 6); @@ -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); } diff --git a/libcxx/test/std/containers/unord/unord.multiset/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/rehash.pass.cpp index bc8d461c60b..5c7c6aa8aad 100644 --- a/libcxx/test/std/containers/unord/unord.multiset/rehash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/rehash.pass.cpp @@ -21,6 +21,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) { assert(c.size() == 6); @@ -48,13 +54,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); } @@ -76,13 +85,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); } diff --git a/libcxx/test/std/containers/unord/unord.set/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.set/rehash.pass.cpp index 30fffa561f7..e28c25dc819 100644 --- a/libcxx/test/std/containers/unord/unord.set/rehash.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/rehash.pass.cpp @@ -21,6 +21,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) { assert(c.size() == 4); @@ -48,13 +54,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); 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); } @@ -76,13 +85,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); 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); } |