Home | History | Annotate | Download | only in string_op_plus_equal
      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 // basic_string<charT,traits,Allocator>& operator+=(charT c);
     13 
     14 #include <string>
     15 #include <cassert>
     16 
     17 #include "min_allocator.h"
     18 
     19 template <class S>
     20 void
     21 test(S s, typename S::value_type str, S expected)
     22 {
     23     s += str;
     24     assert(s.__invariants());
     25     assert(s == expected);
     26 }
     27 
     28 int main()
     29 {
     30     {
     31     typedef std::string S;
     32     test(S(), 'a', S("a"));
     33     test(S("12345"), 'a', S("12345a"));
     34     test(S("1234567890"), 'a', S("1234567890a"));
     35     test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
     36     }
     37 #if __cplusplus >= 201103L
     38     {
     39     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
     40     test(S(), 'a', S("a"));
     41     test(S("12345"), 'a', S("12345a"));
     42     test(S("1234567890"), 'a', S("1234567890a"));
     43     test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
     44     }
     45 #endif
     46 }
     47