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+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); 15 16 // template<class charT, class traits, class Allocator> 17 // basic_string<charT,traits,Allocator>&& 18 // operator+(charT lhs, basic_string<charT,traits,Allocator>&& 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(typename S::value_type lhs, const S& rhs, const S& x) { 29 assert(lhs + rhs == x); 30 } 31 32 #if TEST_STD_VER >= 11 33 template <class S> 34 void test1(typename S::value_type lhs, S&& rhs, const S& x) { 35 assert(lhs + move(rhs) == x); 36 } 37 #endif 38 39 int main() { 40 { 41 typedef std::string S; 42 test0('a', S(""), S("a")); 43 test0('a', S("12345"), S("a12345")); 44 test0('a', S("1234567890"), S("a1234567890")); 45 test0('a', S("12345678901234567890"), S("a12345678901234567890")); 46 } 47 #if TEST_STD_VER >= 11 48 { 49 typedef std::string S; 50 test1('a', S(""), S("a")); 51 test1('a', S("12345"), S("a12345")); 52 test1('a', S("1234567890"), S("a1234567890")); 53 test1('a', S("12345678901234567890"), S("a12345678901234567890")); 54 } 55 { 56 typedef std::basic_string<char, std::char_traits<char>, 57 min_allocator<char> > 58 S; 59 test0('a', S(""), S("a")); 60 test0('a', S("12345"), S("a12345")); 61 test0('a', S("1234567890"), S("a1234567890")); 62 test0('a', S("12345678901234567890"), S("a12345678901234567890")); 63 64 test1('a', S(""), S("a")); 65 test1('a', S("12345"), S("a12345")); 66 test1('a', S("1234567890"), S("a1234567890")); 67 test1('a', S("12345678901234567890"), S("a12345678901234567890")); 68 } 69 #endif 70 } 71