From 53a420fba21cf1644972b34dcd811a43cdb8368d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 2 Jan 2017 19:18:58 +0000 Subject: Vendor import of libc++ trunk r290819: https://llvm.org/svn/llvm-project/libcxx/trunk@290819 --- .../string_assign/iterator.pass.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp') diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp index e6a57519f34b..e5312e6db6ce 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp @@ -179,4 +179,30 @@ 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/"); + } + + { // test assigning a different type + typedef std::string S; + const uint8_t p[] = "ABCD"; + + S s; + s.assign(p, p + 4); + assert(s == "ABCD"); + } } -- cgit v1.2.3