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 <utility> 22 #include <cassert> 23 24 #include "test_macros.h" 25 #include "min_allocator.h" 26 27 template <class S> 28 void test0(const S& lhs, const typename S::value_type* rhs, const S& x) { 29 assert(lhs + rhs == x); 30 } 31 32 #if TEST_STD_VER >= 11 33 template <class S> 34 void test1(S&& lhs, const typename S::value_type* rhs, const S& x) { 35 assert(move(lhs) + rhs == x); 36 } 37 #endif 38 39 int main() { 40 { 41 typedef std::string S; 42 test0(S(""), "", S("")); 43 test0(S(""), "12345", S("12345")); 44 test0(S(""), "1234567890", S("1234567890")); 45 test0(S(""), "12345678901234567890", S("12345678901234567890")); 46 test0(S("abcde"), "", S("abcde")); 47 test0(S("abcde"), "12345", S("abcde12345")); 48 test0(S("abcde"), "1234567890", S("abcde1234567890")); 49 test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); 50 test0(S("abcdefghij"), "", S("abcdefghij")); 51 test0(S("abcdefghij"), "12345", S("abcdefghij12345")); 52 test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); 53 test0(S("abcdefghij"), "12345678901234567890", 54 S("abcdefghij12345678901234567890")); 55 test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); 56 test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); 57 test0(S("abcdefghijklmnopqrst"), "1234567890", 58 S("abcdefghijklmnopqrst1234567890")); 59 test0(S("abcdefghijklmnopqrst"), "12345678901234567890", 60 S("abcdefghijklmnopqrst12345678901234567890")); 61 } 62 #if TEST_STD_VER >= 11 63 { 64 typedef std::string S; 65 test1(S(""), "", S("")); 66 test1(S(""), "12345", S("12345")); 67 test1(S(""), "1234567890", S("1234567890")); 68 test1(S(""), "12345678901234567890", S("12345678901234567890")); 69 test1(S("abcde"), "", S("abcde")); 70 test1(S("abcde"), "12345", S("abcde12345")); 71 test1(S("abcde"), "1234567890", S("abcde1234567890")); 72 test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); 73 test1(S("abcdefghij"), "", S("abcdefghij")); 74 test1(S("abcdefghij"), "12345", S("abcdefghij12345")); 75 test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); 76 test1(S("abcdefghij"), "12345678901234567890", 77 S("abcdefghij12345678901234567890")); 78 test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); 79 test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); 80 test1(S("abcdefghijklmnopqrst"), "1234567890", 81 S("abcdefghijklmnopqrst1234567890")); 82 test1(S("abcdefghijklmnopqrst"), "12345678901234567890", 83 S("abcdefghijklmnopqrst12345678901234567890")); 84 } 85 { 86 typedef std::basic_string<char, std::char_traits<char>, 87 min_allocator<char> > 88 S; 89 test0(S(""), "", S("")); 90 test0(S(""), "12345", S("12345")); 91 test0(S(""), "1234567890", S("1234567890")); 92 test0(S(""), "12345678901234567890", S("12345678901234567890")); 93 test0(S("abcde"), "", S("abcde")); 94 test0(S("abcde"), "12345", S("abcde12345")); 95 test0(S("abcde"), "1234567890", S("abcde1234567890")); 96 test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); 97 test0(S("abcdefghij"), "", S("abcdefghij")); 98 test0(S("abcdefghij"), "12345", S("abcdefghij12345")); 99 test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); 100 test0(S("abcdefghij"), "12345678901234567890", 101 S("abcdefghij12345678901234567890")); 102 test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); 103 test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); 104 test0(S("abcdefghijklmnopqrst"), "1234567890", 105 S("abcdefghijklmnopqrst1234567890")); 106 test0(S("abcdefghijklmnopqrst"), "12345678901234567890", 107 S("abcdefghijklmnopqrst12345678901234567890")); 108 109 test1(S(""), "", S("")); 110 test1(S(""), "12345", S("12345")); 111 test1(S(""), "1234567890", S("1234567890")); 112 test1(S(""), "12345678901234567890", S("12345678901234567890")); 113 test1(S("abcde"), "", S("abcde")); 114 test1(S("abcde"), "12345", S("abcde12345")); 115 test1(S("abcde"), "1234567890", S("abcde1234567890")); 116 test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); 117 test1(S("abcdefghij"), "", S("abcdefghij")); 118 test1(S("abcdefghij"), "12345", S("abcdefghij12345")); 119 test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); 120 test1(S("abcdefghij"), "12345678901234567890", 121 S("abcdefghij12345678901234567890")); 122 test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); 123 test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); 124 test1(S("abcdefghijklmnopqrst"), "1234567890", 125 S("abcdefghijklmnopqrst1234567890")); 126 test1(S("abcdefghijklmnopqrst"), "12345678901234567890", 127 S("abcdefghijklmnopqrst12345678901234567890")); 128 } 129 #endif 130 } 131