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

@@ -61,4 +61,20 @@ int main()
S("1234567890123456789012345678901234567890"));
}
#endif
{ // test appending to self
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
s_short.append(s_short.c_str());
assert(s_short == "123/123/");
s_short.append(s_short.c_str());
assert(s_short == "123/123/123/123/");
s_short.append(s_short.c_str());
assert(s_short == "123/123/123/123/123/123/123/123/");
s_long.append(s_long.c_str());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
}