[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
This commit is contained in:
@@ -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.assign(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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user