summaryrefslogtreecommitdiffstats
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
commit17af2f56ab8a65425804642eb81f2afac46b9168 (patch)
treebc2f866cf301c9a0e04367e802af76cb659f2752
parent938bc1ea843e6e5d64d4d4c33df5ccf40d677344 (diff)
downloadbcm5719-llvm-17af2f56ab8a65425804642eb81f2afac46b9168.tar.gz
bcm5719-llvm-17af2f56ab8a65425804642eb81f2afac46b9168.zip
Add tests for LWG issue #2356. Stability of erasure in unordered associative containers. Libc++ already does this, but now we have tests for it.
llvm-svn: 203494
-rw-r--r--libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp36
-rw-r--r--libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp37
-rw-r--r--libcxx/test/containers/unord/unord.multiset/erase_key.pass.cpp35
-rw-r--r--libcxx/test/containers/unord/unord.set/erase_key.pass.cpp35
-rw-r--r--libcxx/www/cxx1y_status.html2
5 files changed, 144 insertions, 1 deletions
diff --git a/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
index e6741a80efa..0e8ef8b895a 100644
--- a/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
+++ b/libcxx/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/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
index 3c099f32284..892f8a24750 100644
--- a/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
+++ b/libcxx/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/libcxx/test/containers/unord/unord.multiset/erase_key.pass.cpp b/libcxx/test/containers/unord/unord.multiset/erase_key.pass.cpp
index 646d3562582..7c243973f16 100644
--- a/libcxx/test/containers/unord/unord.multiset/erase_key.pass.cpp
+++ b/libcxx/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/libcxx/test/containers/unord/unord.set/erase_key.pass.cpp b/libcxx/test/containers/unord/unord.set/erase_key.pass.cpp
index d97374a4d1e..ca165083b02 100644
--- a/libcxx/test/containers/unord/unord.set/erase_key.pass.cpp
+++ b/libcxx/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/libcxx/www/cxx1y_status.html b/libcxx/www/cxx1y_status.html
index 118963a615b..287c754e8d4 100644
--- a/libcxx/www/cxx1y_status.html
+++ b/libcxx/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>
OpenPOWER on IntegriCloud