summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2019-07-01 19:22:00 +0000
committerMarshall Clow <mclow.lists@gmail.com>2019-07-01 19:22:00 +0000
commit24edf8ef4b5cbb8afabc081b9b196f05868a5364 (patch)
tree1252c5fb2b54dc8f2a3ace52a22a7c06c6a010e9 /libcxx/test/std/containers
parent73dec22c3ef39416c77763e11d2ba93a031ff735 (diff)
downloadbcm5719-llvm-24edf8ef4b5cbb8afabc081b9b196f05868a5364.tar.gz
bcm5719-llvm-24edf8ef4b5cbb8afabc081b9b196f05868a5364.zip
Implement P0646R1: Erase-Like Algorithms Should Return size_type. Reviewed as https://reviews.llvm.org/D58332, and then updated because I rewrote a couple of those routines to eliminate some UB. Thanks to Zoe for tghe patch.
llvm-svn: 364840
Diffstat (limited to 'libcxx/test/std/containers')
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp24
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp20
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp20
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp8
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp6
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp4
6 files changed, 41 insertions, 41 deletions
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
index 3b5e4a21b19..87f3050b745 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
@@ -37,7 +37,7 @@ int main(int, char**)
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.remove(0);
+ assert(c1.remove(0) == 4);
assert(c1 == c2);
}
{
@@ -46,7 +46,7 @@ int main(int, char**)
const T t1[] = {0, 0, 0, 0};
C c1(std::begin(t1), std::end(t1));
C c2;
- c1.remove(0);
+ assert(c1.remove(0) == 4);
assert(c1 == c2);
}
{
@@ -56,7 +56,7 @@ int main(int, char**)
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.remove(0);
+ assert(c1.remove(0) == 0);
assert(c1 == c2);
}
{
@@ -64,7 +64,7 @@ int main(int, char**)
typedef std::forward_list<T> C;
C c1;
C c2;
- c1.remove(0);
+ assert(c1.remove(0) == 0);
assert(c1 == c2);
}
{
@@ -74,7 +74,7 @@ int main(int, char**)
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.remove(0);
+ assert(c1.remove(0) == 1);
assert(c1 == c2);
}
{ // LWG issue #526
@@ -84,7 +84,7 @@ int main(int, char**)
int t2[] = { 2, 3, 5, 8, 11};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.remove(c1.front());
+ assert(c1.remove(c1.front()) == 2);
assert(c1 == c2);
}
{
@@ -95,7 +95,7 @@ int main(int, char**)
C c;
for(int *ip = std::end(t1); ip != std::begin(t1);)
c.push_front(S(*--ip));
- c.remove(c.front());
+ assert(c.remove(c.front()) == 3);
C::const_iterator it = c.begin();
for(int *ip = std::begin(t2); ip != std::end(t2); ++ip, ++it) {
assert ( it != c.end());
@@ -111,7 +111,7 @@ int main(int, char**)
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.remove(0);
+ assert(c1.remove(0) == 4);
assert(c1 == c2);
}
{
@@ -120,7 +120,7 @@ int main(int, char**)
const T t1[] = {0, 0, 0, 0};
C c1(std::begin(t1), std::end(t1));
C c2;
- c1.remove(0);
+ assert(c1.remove(0) == 4);
assert(c1 == c2);
}
{
@@ -130,7 +130,7 @@ int main(int, char**)
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.remove(0);
+ assert(c1.remove(0) == 0);
assert(c1 == c2);
}
{
@@ -138,7 +138,7 @@ int main(int, char**)
typedef std::forward_list<T, min_allocator<T>> C;
C c1;
C c2;
- c1.remove(0);
+ assert(c1.remove(0) == 0);
assert(c1 == c2);
}
{
@@ -148,7 +148,7 @@ int main(int, char**)
const T t2[] = {5, 5, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.remove(0);
+ assert(c1.remove(0) == 1);
assert(c1 == c2);
}
#endif
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
index 2a4f079a3bd..486d355146c 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
@@ -45,7 +45,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 4);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
@@ -57,7 +57,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2;
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 4);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
@@ -70,7 +70,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 0);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
@@ -81,7 +81,7 @@ int main(int, char**)
C c1;
C c2;
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 0);
assert(c1 == c2);
assert(cp.count() == 0);
}
@@ -94,7 +94,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 1);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
@@ -123,7 +123,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 4);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
@@ -135,7 +135,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2;
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 4);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
@@ -148,7 +148,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 0);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
@@ -159,7 +159,7 @@ int main(int, char**)
C c1;
C c2;
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 0);
assert(c1 == c2);
assert(cp.count() == 0);
}
@@ -172,7 +172,7 @@ int main(int, char**)
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
Predicate cp(g);
- c1.remove_if(std::ref(cp));
+ assert(c1.remove_if(std::ref(cp)) == 1);
assert(c1 == c2);
assert(cp.count() == static_cast<std::size_t>(std::distance(std::begin(t1), std::end(t1))));
}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
index 6ce2da57364..32aa8f94a1f 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
@@ -26,7 +26,7 @@ int main(int, char**)
const T t2[] = {0, 5, 0, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 3);
assert(c1 == c2);
}
{
@@ -36,7 +36,7 @@ int main(int, char**)
const T t2[] = {0};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 3);
assert(c1 == c2);
}
{
@@ -46,7 +46,7 @@ int main(int, char**)
const T t2[] = {5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 2);
assert(c1 == c2);
}
{
@@ -54,7 +54,7 @@ int main(int, char**)
typedef std::forward_list<T> C;
C c1;
C c2;
- c1.unique();
+ assert(c1.unique() == 0);
assert(c1 == c2);
}
{
@@ -64,7 +64,7 @@ int main(int, char**)
const T t2[] = {5, 0};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 2);
assert(c1 == c2);
}
#if TEST_STD_VER >= 11
@@ -75,7 +75,7 @@ int main(int, char**)
const T t2[] = {0, 5, 0, 5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 3);
assert(c1 == c2);
}
{
@@ -85,7 +85,7 @@ int main(int, char**)
const T t2[] = {0};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 3);
assert(c1 == c2);
}
{
@@ -95,7 +95,7 @@ int main(int, char**)
const T t2[] = {5};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 2);
assert(c1 == c2);
}
{
@@ -103,7 +103,7 @@ int main(int, char**)
typedef std::forward_list<T, min_allocator<T>> C;
C c1;
C c2;
- c1.unique();
+ assert(c1.unique() == 0);
assert(c1 == c2);
}
{
@@ -113,7 +113,7 @@ int main(int, char**)
const T t2[] = {5, 0};
C c1(std::begin(t1), std::end(t1));
C c2(std::begin(t2), std::end(t2));
- c1.unique();
+ assert(c1.unique() == 2);
assert(c1 == c2);
}
#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp
index dab23f0414f..19a8817144a 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp
@@ -37,7 +37,7 @@ int main(int, char**) {
int a1[] = {1, 2, 3, 4};
int a2[] = {1, 2, 4};
std::list<int> c(a1, a1 + 4);
- c.remove(3);
+ assert(c.remove(3) == 1);
assert(c == std::list<int>(a2, a2 + 3));
}
{ // LWG issue #526
@@ -53,7 +53,7 @@ int main(int, char**) {
std::list<S> c;
for (int *ip = a1; ip < a1 + 8; ++ip)
c.push_back(S(*ip));
- c.remove(c.front());
+ assert(c.remove(c.front()) == 3);
std::list<S>::const_iterator it = c.begin();
for (int *ip = a2; ip < a2 + 5; ++ip, ++it) {
assert(it != c.end());
@@ -67,7 +67,7 @@ int main(int, char**) {
int a1[] = {1, 2, 3, 4};
int a2[] = {1, 2, 4};
List c(a1, a1 + 4, Alloc::create());
- c.remove(3);
+ assert(c.remove(3) == 1);
assert(c == List(a2, a2 + 3, Alloc::create()));
}
#if TEST_STD_VER >= 11
@@ -75,7 +75,7 @@ int main(int, char**) {
int a1[] = {1, 2, 3, 4};
int a2[] = {1, 2, 4};
std::list<int, min_allocator<int>> c(a1, a1 + 4);
- c.remove(3);
+ assert(c.remove(3) == 1);
assert((c == std::list<int, min_allocator<int>>(a2, a2 + 3)));
}
#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
index 37242355e46..d78f7dbb8de 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
@@ -46,7 +46,7 @@ int main(int, char**)
int a2[] = {3, 4};
std::list<int> c(a1, a1+4);
Predicate cp(g);
- c.remove_if(std::ref(cp));
+ assert(c.remove_if(std::ref(cp)) == 2);
assert(c == std::list<int>(a2, a2+2));
assert(cp.count() == 4);
}
@@ -55,7 +55,7 @@ int main(int, char**)
int a2[] = {1, 3};
std::list<int> c(a1, a1+4);
Predicate cp(even);
- c.remove_if(std::ref(cp));
+ assert(c.remove_if(std::ref(cp)) == 2);
assert(c == std::list<int>(a2, a2+2));
assert(cp.count() == 4);
}
@@ -78,7 +78,7 @@ int main(int, char**)
int a2[] = {3, 4};
std::list<int, min_allocator<int>> c(a1, a1+4);
Predicate cp(g);
- c.remove_if(std::ref(cp));
+ assert(c.remove_if(std::ref(cp)) == 2);
assert((c == std::list<int, min_allocator<int>>(a2, a2+2)));
assert(cp.count() == 4);
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
index 90f0fd2f37c..dc80d03762b 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
@@ -22,7 +22,7 @@ int main(int, char**)
int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
int a2[] = {2, 1, 4, 3};
std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
- c.unique();
+ assert(c.unique() == 5);
assert(c == std::list<int>(a2, a2+4));
}
#if TEST_STD_VER >= 11
@@ -30,7 +30,7 @@ int main(int, char**)
int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
int a2[] = {2, 1, 4, 3};
std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
- c.unique();
+ assert(c.unique() == 5);
assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
}
#endif
OpenPOWER on IntegriCloud