1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <string> 10 11 // template<class charT, class traits, class Allocator> 12 // basic_string<charT,traits,Allocator> 13 // operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); 14 15 // template<class charT, class traits, class Allocator> 16 // basic_string<charT,traits,Allocator>&& 17 // operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs); 18 19 #include <string> 20 #include <utility> 21 #include <cassert> 22 23 #include "test_macros.h" 24 #include "min_allocator.h" 25 26 template <class S> 27 void test0(typename S::value_type lhs, const S& rhs, const S& x) { 28 assert(lhs + rhs == x); 29 } 30 31 #if TEST_STD_VER >= 11 32 template <class S> 33 void test1(typename S::value_type lhs, S&& rhs, const S& x) { 34 assert(lhs + move(rhs) == x); 35 } 36 #endif 37 38 int main() { 39 { 40 typedef std::string S; 41 test0('a', S(""), S("a")); 42 test0('a', S("12345"), S("a12345")); 43 test0('a', S("1234567890"), S("a1234567890")); 44 test0('a', S("12345678901234567890"), S("a12345678901234567890")); 45 } 46 #if TEST_STD_VER >= 11 47 { 48 typedef std::string S; 49 test1('a', S(""), S("a")); 50 test1('a', S("12345"), S("a12345")); 51 test1('a', S("1234567890"), S("a1234567890")); 52 test1('a', S("12345678901234567890"), S("a12345678901234567890")); 53 } 54 { 55 typedef std::basic_string<char, std::char_traits<char>, 56 min_allocator<char> > 57 S; 58 test0('a', S(""), S("a")); 59 test0('a', S("12345"), S("a12345")); 60 test0('a', S("1234567890"), S("a1234567890")); 61 test0('a', S("12345678901234567890"), S("a12345678901234567890")); 62 63 test1('a', S(""), S("a")); 64 test1('a', S("12345"), S("a12345")); 65 test1('a', S("1234567890"), S("a1234567890")); 66 test1('a', S("12345678901234567890"), S("a12345678901234567890")); 67 } 68 #endif 69 } 70