Home | History | Annotate | Download | only in string_append
      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 // void push_back(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 c, S expected)
     22 {
     23     s.push_back(c);
     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(1, 'a'));
     33     test(S("12345"), 'a', S("12345a"));
     34     test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
     35     }
     36 #if __cplusplus >= 201103L
     37     {
     38     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
     39     test(S(), 'a', S(1, 'a'));
     40     test(S("12345"), 'a', S("12345a"));
     41     test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
     42     }
     43 #endif
     44 }
     45