diff options
| author | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2021-04-16 17:31:33 -0400 |
|---|---|---|
| committer | Arthur O'Dwyer <arthur.j.odwyer@gmail.com> | 2021-04-26 16:22:43 -0400 |
| commit | 036b80fcbbccee8199851158fd349230aa77d75e (patch) | |
| tree | 05f4a56b399ac320a8cfe57d13b18f4c55562cdc /libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp | |
| parent | e87479b00fcc852a54b79d2fd7f8d779e2b75f68 (diff) | |
[libc++] [test] Improve test_exceptions() in each string.modifiers test.
When checking the strong exception guarantee, also check that
iterators haven't been invalidated.
Reviewed as part of https://reviews.llvm.org/D98573
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp')
| -rw-r--r-- | libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp index 8c0d3d78ab8f..31ba8b05faf3 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp @@ -34,14 +34,21 @@ template <class S, class It> void test_exceptions(S s, It first, It last) { - S aCopy = s; + S original = s; + typename S::iterator begin = s.begin(); + typename S::iterator end = s.end(); + try { s.append(first, last); assert(false); - } - catch (...) {} + } catch (...) {} + + // Part of "no effects" is that iterators and pointers + // into the string must not have been invalidated. LIBCPP_ASSERT(s.__invariants()); - assert(s == aCopy); + assert(s == original); + assert(s.begin() == begin); + assert(s.end() == end); } #endif |
