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.

llvm-svn: 280643
This commit is contained in:
Marshall Clow
2016-09-05 01:54:30 +00:00
parent e9dd46f4d0
commit 7e1a23001d
13 changed files with 226 additions and 13 deletions

View File

@@ -61,4 +61,18 @@ int main()
S("12345678901234567890"));
}
#endif
{ // test assignment to self
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
s_short.assign(s_short.c_str());
assert(s_short == "123/");
s_short.assign(s_short.c_str() + 2);
assert(s_short == "3/");
s_long.assign(s_long.c_str() + 30);
assert(s_long == "nsectetur/");
}
}