libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

string_char.pass.cpp (2111B)


      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, 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, charT rhs);
     19 
     20 #include <string>
     21 #include <utility>
     22 #include <cassert>
     23 
     24 #include "test_macros.h"
     25 #include "min_allocator.h"
     26 
     27 template <class S>
     28 void test0(const S& lhs, typename S::value_type rhs, const S& x) {
     29   assert(lhs + rhs == x);
     30 }
     31 
     32 #if TEST_STD_VER >= 11
     33 template <class S>
     34 void test1(S&& lhs, typename S::value_type rhs, const S& x) {
     35   assert(move(lhs) + rhs == x);
     36 }
     37 #endif
     38 
     39 int main() {
     40   {
     41     typedef std::string S;
     42     test0(S(""), '1', S("1"));
     43     test0(S("abcde"), '1', S("abcde1"));
     44     test0(S("abcdefghij"), '1', S("abcdefghij1"));
     45     test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
     46   }
     47 #if TEST_STD_VER >= 11
     48   {
     49     typedef std::string S;
     50     test1(S(""), '1', S("1"));
     51     test1(S("abcde"), '1', S("abcde1"));
     52     test1(S("abcdefghij"), '1', S("abcdefghij1"));
     53     test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
     54   }
     55   {
     56     typedef std::basic_string<char, std::char_traits<char>,
     57                               min_allocator<char> >
     58         S;
     59     test0(S(""), '1', S("1"));
     60     test0(S("abcde"), '1', S("abcde1"));
     61     test0(S("abcdefghij"), '1', S("abcdefghij1"));
     62     test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
     63 
     64     test1(S(""), '1', S("1"));
     65     test1(S("abcde"), '1', S("abcde1"));
     66     test1(S("abcdefghij"), '1', S("abcdefghij1"));
     67     test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
     68   }
     69 #endif
     70 }