summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-03-10 21:36:36 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-03-10 21:36:36 +0000
commit6dbaaa99a880f356277525c8630491b80d6d2e56 (patch)
tree2b1d797b844fc362eb56184a70041c8bc291b106
parent179e9455a5df659cc1d3da3251834c577e27e2a0 (diff)
downloadlibcxx_35a-6dbaaa99a880f356277525c8630491b80d6d2e56.tar.gz
Add tests for LWG issue #2356. Stability of erasure in unordered associative containers. Libc++ already does this, but now we have tests for it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@203494 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp36
-rw-r--r--test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp37
-rw-r--r--test/containers/unord/unord.multiset/erase_key.pass.cpp35
-rw-r--r--test/containers/unord/unord.set/erase_key.pass.cpp35
-rw-r--r--www/cxx1y_status.html2
5 files changed, 144 insertions, 1 deletions
diff --git a/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
index e6741a80..0e8ef8b8 100644
--- a/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
+++ b/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
@@ -21,6 +21,23 @@
#include "min_allocator.h"
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+
int main()
{
{
@@ -137,5 +154,24 @@ int main()
assert(c.erase(3) == 0);
assert(c.size() == 0);
}
+ {
+ typedef std::unordered_map<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m[i] = i;
+ m2[i] = i;
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
#endif
}
diff --git a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
index 3c099f32..892f8a24 100644
--- a/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
+++ b/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
@@ -21,6 +21,22 @@
#include "min_allocator.h"
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
int main()
{
{
@@ -347,5 +363,26 @@ int main()
assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size());
}
+ {
+ typedef std::unordered_multimap<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ for (int j = 0; j < 2; ++j ) {
+ m.insert (std::make_pair(i,j));
+ m2.insert(std::make_pair(i,j));
+ }
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
#endif
}
diff --git a/test/containers/unord/unord.multiset/erase_key.pass.cpp b/test/containers/unord/unord.multiset/erase_key.pass.cpp
index 646d3562..7c243973 100644
--- a/test/containers/unord/unord.multiset/erase_key.pass.cpp
+++ b/test/containers/unord/unord.multiset/erase_key.pass.cpp
@@ -21,6 +21,22 @@
#include "min_allocator.h"
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
int main()
{
{
@@ -137,5 +153,24 @@ int main()
assert(c.erase(3) == 0);
assert(c.size() == 0);
}
+ {
+ typedef std::unordered_multiset<int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m.insert(i); m.insert(i);
+ m2.insert(i); m2.insert(i);
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
#endif
}
diff --git a/test/containers/unord/unord.set/erase_key.pass.cpp b/test/containers/unord/unord.set/erase_key.pass.cpp
index d97374a4..ca165083 100644
--- a/test/containers/unord/unord.set/erase_key.pass.cpp
+++ b/test/containers/unord/unord.set/erase_key.pass.cpp
@@ -21,6 +21,22 @@
#include "min_allocator.h"
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
int main()
{
{
@@ -136,5 +152,24 @@ int main()
assert(c.erase(3) == 0);
assert(c.size() == 0);
}
+ {
+ typedef std::unordered_set<int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m.insert(i);
+ m2.insert(i);
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
#endif
}
diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html
index 118963a6..287c754e 100644
--- a/www/cxx1y_status.html
+++ b/www/cxx1y_status.html
@@ -262,7 +262,7 @@
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2344">2344</a></td><td>quoted()'s interaction with padding is unclear</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2346">2346</a></td><td>integral_constant's member functions should be marked noexcept</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2350">2350</a></td><td>min, max, and minmax should be constexpr</td><td>Issaquah</td><td>Complete</td></tr>
- <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2356">2356</a></td><td>Stability of erasure in unordered associative containers</td><td>Issaquah</td><td></td></tr>
+ <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2356">2356</a></td><td>Stability of erasure in unordered associative containers</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2357">2357</a></td><td>Remaining "Assignable" requirement</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2359">2359</a></td><td>How does regex_constants::nosubs affect basic_regex::mark_count()?</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360">2360</a></td><td>reverse_iterator::operator*() is unimplementable</td><td>Issaquah</td><td></td></tr>