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