summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/strings/basic.string/string.modifiers/string_assign
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-09-24 22:45:42 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-09-24 22:45:42 +0000
commit54f0981ebda1341b9b2e0ce1ccd830eebc320387 (patch)
treec35544c27df374cf3e6f52a1cc55a0edddd67dc1 /libcxx/test/std/strings/basic.string/string.modifiers/string_assign
parent1776f4c965efb96488d857a86acd369cf747a257 (diff)
downloadbcm5719-llvm-54f0981ebda1341b9b2e0ce1ccd830eebc320387.tar.gz
bcm5719-llvm-54f0981ebda1341b9b2e0ce1ccd830eebc320387.zip
Implement proposed resolution for LWG#2758. Reviewed as D24446. Normally, I would wait for these to be voted upon at a committee meeting (November), but the current draft standard is broken, and this should fix it. (And if it doesn't, we want to know about it soonest)
llvm-svn: 282342
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.modifiers/string_assign')
-rw-r--r--libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp (renamed from libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_view_size_size.pass.cpp)62
1 files changed, 59 insertions, 3 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_view_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
index 1eb18d8bffa..8b089c493c1 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_view_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
@@ -10,9 +10,8 @@
// XFAIL: libcpp-no-exceptions
// <string>
-// basic_string<charT,traits,Allocator>&
-// assign(basic_string_view<charT,traits> sv, size_type pos, size_type n=npos);
-// the =npos was added for C++14
+// template <class T>
+// basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17
#include <string>
#include <stdexcept>
@@ -120,4 +119,61 @@ int main()
test_npos(S(), SV("12345"), 5, S(""));
test_npos(S(), SV("12345"), 6, S("not happening"));
}
+ {
+ typedef std::string S;
+ typedef std::string_view SV;
+ S s = "ABCD";
+ SV sv = "EFGH";
+ char arr[] = "IJKL";
+
+ s.assign("CDEF", 0); // calls assign(const char *, len)
+ assert(s == "");
+ s.clear();
+
+ s.assign("QRST", 0, std::string::npos); // calls assign(string("QRST", pos, len)
+ assert(s == "QRST");
+ s.clear();
+
+ s.assign(sv, 0); // calls assign(T, pos, npos)
+ assert(s == sv);
+ s.clear();
+
+ s.assign(sv, 0, std::string::npos); // calls assign(T, pos, npos)
+ assert(s == sv);
+ s.clear();
+
+ s.assign(arr, 0); // calls assign(const char *, len)
+ assert(s == "");
+ s.clear();
+
+ s.assign(arr, 0, std::string::npos); // calls assign(string("IJKL"), pos, npos)
+ assert(s == "IJKL");
+ s.clear();
+
+ s.assign(arr, 0); // calls assign(const char *, len)
+ assert(s == "");
+ s.clear();
+
+ {
+ S s = "ABCD";
+ SV sv = s;
+ s.assign(sv);
+ assert(s == "ABCD");
+
+ sv = s;
+ s.assign(sv, 0, std::string::npos);
+ assert(s == "ABCD");
+ }
+
+ {
+ S s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ SV sv = s;
+ s.assign(sv);
+ assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+
+ sv = s;
+ s.assign(sv, 0, std::string::npos);
+ assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ }
+ }
}
OpenPOWER on IntegriCloud