Home | History | Annotate | Download | only in string_op+
      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,
     15 //             const basic_string<charT,traits,Allocator>& rhs);
     16 
     17 // template<class charT, class traits, class Allocator>
     18 //   basic_string<charT,traits,Allocator>&&
     19 //   operator+(const basic_string<charT,traits,Allocator>&& lhs,
     20 //             const basic_string<charT,traits,Allocator>& rhs);
     21 
     22 // template<class charT, class traits, class Allocator>
     23 //   basic_string<charT,traits,Allocator>&&
     24 //   operator+(const basic_string<charT,traits,Allocator>& lhs,
     25 //             const basic_string<charT,traits,Allocator>&& rhs);
     26 
     27 // template<class charT, class traits, class Allocator>
     28 //   basic_string<charT,traits,Allocator>&&
     29 //   operator+(const basic_string<charT,traits,Allocator>&& lhs,
     30 //             const basic_string<charT,traits,Allocator>&& rhs);
     31 
     32 #include <string>
     33 #include <cassert>
     34 
     35 template <class S>
     36 void
     37 test0(const S& lhs, const S& rhs, const S& x)
     38 {
     39     assert(lhs + rhs == x);
     40 }
     41 
     42 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     43 
     44 template <class S>
     45 void
     46 test1(S&& lhs, const S& rhs, const S& x)
     47 {
     48     assert(move(lhs) + rhs == x);
     49 }
     50 
     51 template <class S>
     52 void
     53 test2(const S& lhs, S&& rhs, const S& x)
     54 {
     55     assert(lhs + move(rhs) == x);
     56 }
     57 
     58 template <class S>
     59 void
     60 test3(S&& lhs, S&& rhs, const S& x)
     61 {
     62     assert(move(lhs) + move(rhs) == x);
     63 }
     64 
     65 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     66 
     67 typedef std::string S;
     68 
     69 int main()
     70 {
     71     test0(S(""), S(""), S(""));
     72     test0(S(""), S("12345"), S("12345"));
     73     test0(S(""), S("1234567890"), S("1234567890"));
     74     test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
     75     test0(S("abcde"), S(""), S("abcde"));
     76     test0(S("abcde"), S("12345"), S("abcde12345"));
     77     test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
     78     test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
     79     test0(S("abcdefghij"), S(""), S("abcdefghij"));
     80     test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
     81     test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
     82     test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
     83     test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
     84     test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
     85     test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
     86     test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
     87 
     88 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     89 
     90     test1(S(""), S(""), S(""));
     91     test1(S(""), S("12345"), S("12345"));
     92     test1(S(""), S("1234567890"), S("1234567890"));
     93     test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
     94     test1(S("abcde"), S(""), S("abcde"));
     95     test1(S("abcde"), S("12345"), S("abcde12345"));
     96     test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
     97     test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
     98     test1(S("abcdefghij"), S(""), S("abcdefghij"));
     99     test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
    100     test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
    101     test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
    102     test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
    103     test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
    104     test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
    105     test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
    106 
    107     test2(S(""), S(""), S(""));
    108     test2(S(""), S("12345"), S("12345"));
    109     test2(S(""), S("1234567890"), S("1234567890"));
    110     test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
    111     test2(S("abcde"), S(""), S("abcde"));
    112     test2(S("abcde"), S("12345"), S("abcde12345"));
    113     test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
    114     test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
    115     test2(S("abcdefghij"), S(""), S("abcdefghij"));
    116     test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
    117     test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
    118     test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
    119     test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
    120     test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
    121     test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
    122     test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
    123 
    124     test3(S(""), S(""), S(""));
    125     test3(S(""), S("12345"), S("12345"));
    126     test3(S(""), S("1234567890"), S("1234567890"));
    127     test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
    128     test3(S("abcde"), S(""), S("abcde"));
    129     test3(S("abcde"), S("12345"), S("abcde12345"));
    130     test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
    131     test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
    132     test3(S("abcdefghij"), S(""), S("abcdefghij"));
    133     test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
    134     test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
    135     test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
    136     test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
    137     test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
    138     test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
    139     test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
    140 
    141 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
    142 }
    143