Fix Bug 30240 - std::string: append(first, last) error when aliasing. Add test cases for append/insert/assign/replace while we're at it, and fix a similar bug in insert.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@280643 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2016-09-05 01:54:30 +00:00
parent 4dbd4fcf86
commit d979eed766
13 changed files with 226 additions and 13 deletions

View File

@@ -179,4 +179,21 @@ int main()
test_exceptions(S(), TIter(s, s+10, 6, TIter::TAComparison), TIter());
}
#endif
{ // test assigning to self
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
s_short.assign(s_short.begin(), s_short.end());
assert(s_short == "123/");
s_short.assign(s_short.begin() + 2, s_short.end());
assert(s_short == "3/");
s_long.assign(s_long.begin(), s_long.end());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/");
s_long.assign(s_long.begin() + 30, s_long.end());
assert(s_long == "nsectetur/");
}
}