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