[libcxx] r253223 - 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.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 16 08:42:16 PST 2015
Author: marshall
Date: Mon Nov 16 10:42:16 2015
New Revision: 253223
URL: http://llvm.org/viewvc/llvm-project?rev=253223&view=rev
Log:
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.
Modified:
libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/rehash.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/rehash.pass.cpp
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp?rev=253223&r1=253222&r2=253223&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/rehash.pass.cpp Mon Nov 16 10:42:16 2015
@@ -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);
}
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp?rev=253223&r1=253222&r2=253223&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp Mon Nov 16 10:42:16 2015
@@ -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);
}
Modified: libcxx/trunk/test/std/containers/unord/unord.multiset/rehash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/rehash.pass.cpp?rev=253223&r1=253222&r2=253223&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multiset/rehash.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multiset/rehash.pass.cpp Mon Nov 16 10:42:16 2015
@@ -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);
}
Modified: libcxx/trunk/test/std/containers/unord/unord.set/rehash.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.set/rehash.pass.cpp?rev=253223&r1=253222&r2=253223&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.set/rehash.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.set/rehash.pass.cpp Mon Nov 16 10:42:16 2015
@@ -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);
}
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=253223&r1=253222&r2=253223&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Nov 16 10:42:16 2015
@@ -154,7 +154,7 @@
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2119">2119</a></td><td>Missing <tt>hash</tt> specializations for extended integer types</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2127">2127</a></td><td>Move-construction with <tt>raw_storage_iterator</tt></td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2133">2133</a></td><td>Attitude to overloaded comma for iterators</td><td>Kona</td><td>Complete</td></tr>
- <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2156">2156</a></td><td>Unordered containers' <tt>reserve(n)</tt> reserves for <tt>n-1</tt> elements</td><td>Kona</td><td></td></tr>
+ <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2156">2156</a></td><td>Unordered containers' <tt>reserve(n)</tt> reserves for <tt>n-1</tt> elements</td><td>Kona</td><td>Complete</td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2218">2218</a></td><td>Unclear how containers use <tt>allocator_traits::construct()</tt></td><td>Kona</td><td></td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2219">2219</a></td><td><tt><i>INVOKE</i></tt>-ing a pointer to member with a <tt>reference_wrapper</tt> as the object expression</td><td>Kona</td><td></td></tr>
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2224">2224</a></td><td>Ambiguous status of access to non-live objects</td><td>Kona</td><td>Complete</td></tr>
More information about the cfe-commits
mailing list