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, 15 // const basic_string<charT,traits,Allocator>& rhs); 16 17 // template<class charT, class traits, class Allocator> 18 // basic_string<charT,traits,Allocator>&& 19 // operator+(const basic_string<charT,traits,Allocator>&& lhs, 20 // const basic_string<charT,traits,Allocator>& rhs); 21 22 // template<class charT, class traits, class Allocator> 23 // basic_string<charT,traits,Allocator>&& 24 // operator+(const basic_string<charT,traits,Allocator>& lhs, 25 // const basic_string<charT,traits,Allocator>&& rhs); 26 27 // template<class charT, class traits, class Allocator> 28 // basic_string<charT,traits,Allocator>&& 29 // operator+(const basic_string<charT,traits,Allocator>&& lhs, 30 // const basic_string<charT,traits,Allocator>&& rhs); 31 32 #include <string> 33 #include <utility> 34 #include <cassert> 35 36 #include "min_allocator.h" 37 38 template <class S> 39 void 40 test0(const S& lhs, const S& rhs, const S& x) 41 { 42 assert(lhs + rhs == x); 43 } 44 45 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 46 47 template <class S> 48 void 49 test1(S&& lhs, const S& rhs, const S& x) 50 { 51 assert(move(lhs) + rhs == x); 52 } 53 54 template <class S> 55 void 56 test2(const S& lhs, S&& rhs, const S& x) 57 { 58 assert(lhs + move(rhs) == x); 59 } 60 61 template <class S> 62 void 63 test3(S&& lhs, S&& rhs, const S& x) 64 { 65 assert(move(lhs) + move(rhs) == x); 66 } 67 68 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 69 70 int main() 71 { 72 { 73 typedef std::string S; 74 test0(S(""), S(""), S("")); 75 test0(S(""), S("12345"), S("12345")); 76 test0(S(""), S("1234567890"), S("1234567890")); 77 test0(S(""), S("12345678901234567890"), S("12345678901234567890")); 78 test0(S("abcde"), S(""), S("abcde")); 79 test0(S("abcde"), S("12345"), S("abcde12345")); 80 test0(S("abcde"), S("1234567890"), S("abcde1234567890")); 81 test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 82 test0(S("abcdefghij"), S(""), S("abcdefghij")); 83 test0(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 84 test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 85 test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 86 test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 87 test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 88 test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 89 test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 90 91 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 92 93 test1(S(""), S(""), S("")); 94 test1(S(""), S("12345"), S("12345")); 95 test1(S(""), S("1234567890"), S("1234567890")); 96 test1(S(""), S("12345678901234567890"), S("12345678901234567890")); 97 test1(S("abcde"), S(""), S("abcde")); 98 test1(S("abcde"), S("12345"), S("abcde12345")); 99 test1(S("abcde"), S("1234567890"), S("abcde1234567890")); 100 test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 101 test1(S("abcdefghij"), S(""), S("abcdefghij")); 102 test1(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 103 test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 104 test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 105 test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 106 test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 107 test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 108 test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 109 110 test2(S(""), S(""), S("")); 111 test2(S(""), S("12345"), S("12345")); 112 test2(S(""), S("1234567890"), S("1234567890")); 113 test2(S(""), S("12345678901234567890"), S("12345678901234567890")); 114 test2(S("abcde"), S(""), S("abcde")); 115 test2(S("abcde"), S("12345"), S("abcde12345")); 116 test2(S("abcde"), S("1234567890"), S("abcde1234567890")); 117 test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 118 test2(S("abcdefghij"), S(""), S("abcdefghij")); 119 test2(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 120 test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 121 test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 122 test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 123 test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 124 test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 125 test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 126 127 test3(S(""), S(""), S("")); 128 test3(S(""), S("12345"), S("12345")); 129 test3(S(""), S("1234567890"), S("1234567890")); 130 test3(S(""), S("12345678901234567890"), S("12345678901234567890")); 131 test3(S("abcde"), S(""), S("abcde")); 132 test3(S("abcde"), S("12345"), S("abcde12345")); 133 test3(S("abcde"), S("1234567890"), S("abcde1234567890")); 134 test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 135 test3(S("abcdefghij"), S(""), S("abcdefghij")); 136 test3(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 137 test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 138 test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 139 test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 140 test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 141 test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 142 test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 143 144 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 145 } 146 #if __cplusplus >= 201103L 147 { 148 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 149 test0(S(""), S(""), S("")); 150 test0(S(""), S("12345"), S("12345")); 151 test0(S(""), S("1234567890"), S("1234567890")); 152 test0(S(""), S("12345678901234567890"), S("12345678901234567890")); 153 test0(S("abcde"), S(""), S("abcde")); 154 test0(S("abcde"), S("12345"), S("abcde12345")); 155 test0(S("abcde"), S("1234567890"), S("abcde1234567890")); 156 test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 157 test0(S("abcdefghij"), S(""), S("abcdefghij")); 158 test0(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 159 test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 160 test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 161 test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 162 test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 163 test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 164 test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 165 166 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 167 168 test1(S(""), S(""), S("")); 169 test1(S(""), S("12345"), S("12345")); 170 test1(S(""), S("1234567890"), S("1234567890")); 171 test1(S(""), S("12345678901234567890"), S("12345678901234567890")); 172 test1(S("abcde"), S(""), S("abcde")); 173 test1(S("abcde"), S("12345"), S("abcde12345")); 174 test1(S("abcde"), S("1234567890"), S("abcde1234567890")); 175 test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 176 test1(S("abcdefghij"), S(""), S("abcdefghij")); 177 test1(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 178 test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 179 test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 180 test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 181 test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 182 test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 183 test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 184 185 test2(S(""), S(""), S("")); 186 test2(S(""), S("12345"), S("12345")); 187 test2(S(""), S("1234567890"), S("1234567890")); 188 test2(S(""), S("12345678901234567890"), S("12345678901234567890")); 189 test2(S("abcde"), S(""), S("abcde")); 190 test2(S("abcde"), S("12345"), S("abcde12345")); 191 test2(S("abcde"), S("1234567890"), S("abcde1234567890")); 192 test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 193 test2(S("abcdefghij"), S(""), S("abcdefghij")); 194 test2(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 195 test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 196 test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 197 test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 198 test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 199 test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 200 test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 201 202 test3(S(""), S(""), S("")); 203 test3(S(""), S("12345"), S("12345")); 204 test3(S(""), S("1234567890"), S("1234567890")); 205 test3(S(""), S("12345678901234567890"), S("12345678901234567890")); 206 test3(S("abcde"), S(""), S("abcde")); 207 test3(S("abcde"), S("12345"), S("abcde12345")); 208 test3(S("abcde"), S("1234567890"), S("abcde1234567890")); 209 test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); 210 test3(S("abcdefghij"), S(""), S("abcdefghij")); 211 test3(S("abcdefghij"), S("12345"), S("abcdefghij12345")); 212 test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); 213 test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); 214 test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); 215 test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); 216 test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); 217 test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); 218 219 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 220 } 221 #endif 222 } 223