1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <string> 11 12 // template<class charT, class traits, class Allocator> 13 // basic_string<charT,traits,Allocator> 14 // operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); 15 16 // template<class charT, class traits, class Allocator> 17 // basic_string<charT,traits,Allocator>&& 18 // operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs); 19 20 #include <string> 21 #include <cassert> 22 23 template <class S> 24 void 25 test0(const S& lhs, const typename S::value_type* rhs, const S& x) 26 { 27 assert(lhs + rhs == x); 28 } 29 30 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 31 32 template <class S> 33 void 34 test1(S&& lhs, const typename S::value_type* rhs, const S& x) 35 { 36 assert(move(lhs) + rhs == x); 37 } 38 39 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 40 41 typedef std::string S; 42 43 int main() 44 { 45 test0(S(""), "", S("")); 46 test0(S(""), "12345", S("12345")); 47 test0(S(""), "1234567890", S("1234567890")); 48 test0(S(""), "12345678901234567890", S("12345678901234567890")); 49 test0(S("abcde"), "", S("abcde")); 50 test0(S("abcde"), "12345", S("abcde12345")); 51 test0(S("abcde"), "1234567890", S("abcde1234567890")); 52 test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); 53 test0(S("abcdefghij"), "", S("abcdefghij")); 54 test0(S("abcdefghij"), "12345", S("abcdefghij12345")); 55 test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); 56 test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); 57 test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); 58 test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); 59 test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); 60 test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); 61 62 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 63 64 test1(S(""), "", S("")); 65 test1(S(""), "12345", S("12345")); 66 test1(S(""), "1234567890", S("1234567890")); 67 test1(S(""), "12345678901234567890", S("12345678901234567890")); 68 test1(S("abcde"), "", S("abcde")); 69 test1(S("abcde"), "12345", S("abcde12345")); 70 test1(S("abcde"), "1234567890", S("abcde1234567890")); 71 test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); 72 test1(S("abcdefghij"), "", S("abcdefghij")); 73 test1(S("abcdefghij"), "12345", S("abcdefghij12345")); 74 test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); 75 test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); 76 test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); 77 test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); 78 test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); 79 test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); 80 81 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 82 } 83