diff options
Diffstat (limited to 'libcxx/test')
2 files changed, 26 insertions, 13 deletions
diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp index 362ad5487c3..f322dce206f 100644 --- a/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp @@ -9,7 +9,7 @@ // <forward_list> -// void erase_after(const_iterator first, const_iterator last); +// iterator erase_after(const_iterator first, const_iterator last); #include <forward_list> #include <cassert> @@ -22,7 +22,8 @@ int main() const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c(std::begin(t), std::end(t)); - c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4)); + C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4)); + assert(i == next(c.cbefore_begin(), 4)); assert(distance(c.begin(), c.end()) == 10); assert(*next(c.begin(), 0) == 0); assert(*next(c.begin(), 1) == 1); @@ -35,7 +36,8 @@ int main() assert(*next(c.begin(), 8) == 8); assert(*next(c.begin(), 9) == 9); - c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5)); + i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5)); + assert(i == next(c.begin(), 2)); assert(distance(c.begin(), c.end()) == 8); assert(*next(c.begin(), 0) == 0); assert(*next(c.begin(), 1) == 1); @@ -46,7 +48,8 @@ int main() assert(*next(c.begin(), 6) == 8); assert(*next(c.begin(), 7) == 9); - c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3)); + i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3)); + assert(i == next(c.begin(), 2)); assert(distance(c.begin(), c.end()) == 8); assert(*next(c.begin(), 0) == 0); assert(*next(c.begin(), 1) == 1); @@ -57,7 +60,8 @@ int main() assert(*next(c.begin(), 6) == 8); assert(*next(c.begin(), 7) == 9); - c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9)); + i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9)); + assert(i == c.end()); assert(distance(c.begin(), c.end()) == 5); assert(*next(c.begin(), 0) == 0); assert(*next(c.begin(), 1) == 1); @@ -65,14 +69,17 @@ int main() assert(*next(c.begin(), 3) == 5); assert(*next(c.begin(), 4) == 6); - c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2)); + i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2)); + assert(i == c.begin()); assert(distance(c.begin(), c.end()) == 4); assert(*next(c.begin(), 0) == 1); assert(*next(c.begin(), 1) == 4); assert(*next(c.begin(), 2) == 5); assert(*next(c.begin(), 3) == 6); - c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5)); + i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5)); + assert(i == c.begin()); + assert(i == c.end()); assert(distance(c.begin(), c.end()) == 0); } } diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp index f7c40d6a604..03c2a8fd45b 100644 --- a/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp @@ -9,7 +9,7 @@ // <forward_list> -// void erase_after(const_iterator p); +// iterator erase_after(const_iterator p); #include <forward_list> #include <cassert> @@ -22,29 +22,35 @@ int main() const T t[] = {0, 1, 2, 3, 4}; C c(std::begin(t), std::end(t)); - c.erase_after(next(c.cbefore_begin(), 4)); + C::iterator i = c.erase_after(next(c.cbefore_begin(), 4)); + assert(i == c.end()); assert(distance(c.begin(), c.end()) == 4); assert(*next(c.begin(), 0) == 0); assert(*next(c.begin(), 1) == 1); assert(*next(c.begin(), 2) == 2); assert(*next(c.begin(), 3) == 3); - c.erase_after(next(c.cbefore_begin(), 0)); + i = c.erase_after(next(c.cbefore_begin(), 0)); + assert(i == c.begin()); assert(distance(c.begin(), c.end()) == 3); assert(*next(c.begin(), 0) == 1); assert(*next(c.begin(), 1) == 2); assert(*next(c.begin(), 2) == 3); - c.erase_after(next(c.cbefore_begin(), 1)); + i = c.erase_after(next(c.cbefore_begin(), 1)); + assert(i == next(c.begin())); assert(distance(c.begin(), c.end()) == 2); assert(*next(c.begin(), 0) == 1); assert(*next(c.begin(), 1) == 3); - c.erase_after(next(c.cbefore_begin(), 1)); + i = c.erase_after(next(c.cbefore_begin(), 1)); + assert(i == c.end()); assert(distance(c.begin(), c.end()) == 1); assert(*next(c.begin(), 0) == 1); - c.erase_after(next(c.cbefore_begin(), 0)); + i = c.erase_after(next(c.cbefore_begin(), 0)); + assert(i == c.begin()); + assert(i == c.end()); assert(distance(c.begin(), c.end()) == 0); } } |