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 "min_allocator.h"
25
26 template <class S>
27 void
test0(const S & lhs,const typename S::value_type * rhs,const S & x)28 test0(const S& lhs, const typename S::value_type* rhs, const S& x)
29 {
30 assert(lhs + rhs == x);
31 }
32
33 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
34
35 template <class S>
36 void
test1(S && lhs,const typename S::value_type * rhs,const S & x)37 test1(S&& lhs, const typename S::value_type* rhs, const S& x)
38 {
39 assert(move(lhs) + rhs == x);
40 }
41
42 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
43
main()44 int main()
45 {
46 {
47 typedef std::string S;
48 test0(S(""), "", S(""));
49 test0(S(""), "12345", S("12345"));
50 test0(S(""), "1234567890", S("1234567890"));
51 test0(S(""), "12345678901234567890", S("12345678901234567890"));
52 test0(S("abcde"), "", S("abcde"));
53 test0(S("abcde"), "12345", S("abcde12345"));
54 test0(S("abcde"), "1234567890", S("abcde1234567890"));
55 test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
56 test0(S("abcdefghij"), "", S("abcdefghij"));
57 test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
58 test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
59 test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
60 test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
61 test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
62 test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
63 test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
64
65 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
66
67 test1(S(""), "", S(""));
68 test1(S(""), "12345", S("12345"));
69 test1(S(""), "1234567890", S("1234567890"));
70 test1(S(""), "12345678901234567890", S("12345678901234567890"));
71 test1(S("abcde"), "", S("abcde"));
72 test1(S("abcde"), "12345", S("abcde12345"));
73 test1(S("abcde"), "1234567890", S("abcde1234567890"));
74 test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
75 test1(S("abcdefghij"), "", S("abcdefghij"));
76 test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
77 test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
78 test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
79 test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
80 test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
81 test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
82 test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
83
84 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
85 }
86 #if __cplusplus >= 201103L
87 {
88 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> 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", S("abcdefghij12345678901234567890"));
101 test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
102 test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
103 test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
104 test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
105
106 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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", S("abcdefghij12345678901234567890"));
120 test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
121 test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
122 test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
123 test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
124
125 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
126 }
127 #endif
128 }
129