diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2019-07-06 06:10:03 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2019-07-06 06:10:03 +0000 |
commit | 1ab3fe8a7a6537f882bbb2dac72c479d05eb8c49 (patch) | |
tree | fd7226f53819f56e3cf932c064f45f361b5fed9d /libcxx/test/std | |
parent | 9812668d77121498cade95dc89526dc78a210251 (diff) | |
download | bcm5719-llvm-1ab3fe8a7a6537f882bbb2dac72c479d05eb8c49.tar.gz bcm5719-llvm-1ab3fe8a7a6537f882bbb2dac72c479d05eb8c49.zip |
Make list::remove/remove_if/unique all return void before C++20; undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out
llvm-svn: 365261
Diffstat (limited to 'libcxx/test/std')
4 files changed, 84 insertions, 19 deletions
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 19a8817144a..8c9a06273f3 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 @@ -8,7 +8,8 @@ // <list> -// void remove(const value_type& value); +// void remove(const value_type& value); // pre-c++20 +// size_type remove(const value_type& value); // c++20 and later #include <list> #include <cassert> @@ -36,8 +37,16 @@ int main(int, char**) { { int a1[] = {1, 2, 3, 4}; int a2[] = {1, 2, 4}; - std::list<int> c(a1, a1 + 4); + typedef std::list<int> L; + L c(a1, a1 + 4); +#if TEST_STD_VER > 17 assert(c.remove(3) == 1); + ASSERT_SAME_TYPE(L::size_type, decltype(c.remove(3))); +#else + ASSERT_SAME_TYPE(void, decltype(c.remove(3))); + c.remove(3); +#endif + assert(c == std::list<int>(a2, a2 + 3)); } { // LWG issue #526 @@ -53,7 +62,11 @@ int main(int, char**) { std::list<S> c; for (int *ip = a1; ip < a1 + 8; ++ip) c.push_back(S(*ip)); +#if TEST_STD_VER > 17 assert(c.remove(c.front()) == 3); +#else + c.remove(c.front()); +#endif std::list<S>::const_iterator it = c.begin(); for (int *ip = a2; ip < a2 + 5; ++ip, ++it) { assert(it != c.end()); @@ -67,7 +80,11 @@ int main(int, char**) { int a1[] = {1, 2, 3, 4}; int a2[] = {1, 2, 4}; List c(a1, a1 + 4, Alloc::create()); - assert(c.remove(3) == 1); +#if TEST_STD_VER > 17 + assert(c.remove(3) == 1); +#else + c.remove(3); +#endif assert(c == List(a2, a2 + 3, Alloc::create())); } #if TEST_STD_VER >= 11 @@ -75,7 +92,11 @@ 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); +#if TEST_STD_VER > 17 assert(c.remove(3) == 1); +#else + c.remove(3); +#endif 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 d78f7dbb8de..0944e685ce4 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 @@ -8,7 +8,8 @@ // <list> -// template <class Pred> void remove_if(Pred pred); +// template <class Pred> void remove_if(Pred pred); // before C++20 +// template <class Pred> size_type remove_if(Pred pred); // c++20 and later #include <list> #include <cassert> @@ -28,10 +29,10 @@ bool g(int i) return i < 3; } -struct PredLWG529 { - PredLWG529 (int i) : i_(i) {}; - ~PredLWG529() { i_ = -32767; } - bool operator() (const PredLWG529 &p) const { return p.i_ == i_; } +struct PredLWG526 { + PredLWG526 (int i) : i_(i) {}; + ~PredLWG526() { i_ = -32767; } + bool operator() (const PredLWG526 &p) const { return p.i_ == i_; } bool operator==(int i) const { return i == i_;} int i_; @@ -44,9 +45,16 @@ int main(int, char**) { int a1[] = {1, 2, 3, 4}; int a2[] = {3, 4}; - std::list<int> c(a1, a1+4); + typedef std::list<int> L; + L c(a1, a1+4); Predicate cp(g); +#if TEST_STD_VER > 17 + ASSERT_SAME_TYPE(L::size_type, decltype(c.remove_if(std::ref(cp)))); assert(c.remove_if(std::ref(cp)) == 2); +#else + ASSERT_SAME_TYPE(void, decltype(c.remove_if(std::ref(cp)))); + c.remove_if(std::ref(cp)); +#endif assert(c == std::list<int>(a2, a2+2)); assert(cp.count() == 4); } @@ -55,14 +63,18 @@ int main(int, char**) int a2[] = {1, 3}; std::list<int> c(a1, a1+4); Predicate cp(even); +#if TEST_STD_VER > 17 assert(c.remove_if(std::ref(cp)) == 2); +#else + c.remove_if(std::ref(cp)); +#endif assert(c == std::list<int>(a2, a2+2)); assert(cp.count() == 4); } { // LWG issue #526 int a1[] = {1, 2, 1, 3, 5, 8, 11}; int a2[] = {2, 3, 5, 8, 11}; - std::list<PredLWG529> c(a1, a1 + 7); + std::list<PredLWG526> c(a1, a1 + 7); c.remove_if(std::ref(c.front())); assert(c.size() == 5); for (size_t i = 0; i < c.size(); ++i) @@ -78,7 +90,11 @@ int main(int, char**) int a2[] = {3, 4}; std::list<int, min_allocator<int>> c(a1, a1+4); Predicate cp(g); +#if TEST_STD_VER > 17 assert(c.remove_if(std::ref(cp)) == 2); +#else + c.remove_if(std::ref(cp)); +#endif 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 dc80d03762b..85c4ec587c1 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 @@ -8,7 +8,8 @@ // <list> -// void unique(); +// void unique(); // before C++20 +// size_type unique(); // C++20 and later #include <list> #include <cassert> @@ -21,8 +22,15 @@ 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])); + typedef std::list<int> L; + L c(a1, a1+sizeof(a1)/sizeof(a1[0])); +#if TEST_STD_VER > 17 + ASSERT_SAME_TYPE(L::size_type, decltype(c.unique())); assert(c.unique() == 5); +#else + ASSERT_SAME_TYPE(void, decltype(c.unique())); + c.unique(); +#endif assert(c == std::list<int>(a2, a2+4)); } #if TEST_STD_VER >= 11 @@ -30,7 +38,11 @@ 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])); +#if TEST_STD_VER > 17 assert(c.unique() == 5); +#else + c.unique(); +#endif assert((c == std::list<int, min_allocator<int>>(a2, a2+4))); } #endif diff --git a/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp index 6338324bcfa..75f8c7b1257 100644 --- a/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp @@ -8,7 +8,8 @@ // <list> -// template <class BinaryPred> void unique(BinaryPred pred); +// template <class BinaryPred> void unique(BinaryPred pred); // before C++20 +// template <class BinaryPred> size_type unique(BinaryPred pred); // C++20 and later #include <list> #include <cassert> @@ -21,10 +22,10 @@ bool g(int x, int y) return x == y; } -struct PredLWG529 { - PredLWG529 (int i) : i_(i) {}; - ~PredLWG529() { i_ = -32767; } - bool operator() (const PredLWG529 &lhs, const PredLWG529 &rhs) const { return lhs.i_ == rhs.i_; } +struct PredLWG526 { + PredLWG526 (int i) : i_(i) {}; + ~PredLWG526() { i_ = -32767; } + bool operator() (const PredLWG526 &lhs, const PredLWG526 &rhs) const { return lhs.i_ == rhs.i_; } bool operator==(int i) const { return i == i_;} int i_; @@ -35,16 +36,27 @@ 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])); + typedef std::list<int> L; + L c(a1, a1+sizeof(a1)/sizeof(a1[0])); +#if TEST_STD_VER > 17 + ASSERT_SAME_TYPE(L::size_type, decltype(c.unique(g))); + assert(c.unique(g) == 5); +#else + ASSERT_SAME_TYPE(void, decltype(c.unique(g))); c.unique(g); +#endif assert(c == std::list<int>(a2, a2+4)); } { // LWG issue #526 int a1[] = {1, 1, 1, 2, 3, 5, 5, 2, 11}; int a2[] = {1, 2, 3, 5, 2, 11}; - std::list<PredLWG529> c(a1, a1 + 9); + std::list<PredLWG526> c(a1, a1 + 9); +#if TEST_STD_VER > 17 + assert(c.unique(std::ref(c.front())) == 3); +#else c.unique(std::ref(c.front())); +#endif assert(c.size() == 6); for (size_t i = 0; i < c.size(); ++i) { @@ -58,7 +70,11 @@ 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])); +#if TEST_STD_VER > 17 + assert(c.unique(g) == 5); +#else c.unique(g); +#endif assert((c == std::list<int, min_allocator<int>>(a2, a2+4))); } #endif |