• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "test_macros.h"
18 #include "min_allocator.h"
19 
20 template <class S>
21 void
test(S s,typename S::value_type c,S expected)22 test(S s, typename S::value_type c, S expected)
23 {
24     s.push_back(c);
25     LIBCPP_ASSERT(s.__invariants());
26     assert(s == expected);
27 }
28 
main()29 int main()
30 {
31     {
32     typedef std::string S;
33     test(S(), 'a', S(1, 'a'));
34     test(S("12345"), 'a', S("12345a"));
35     test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
36     }
37 #if TEST_STD_VER >= 11
38     {
39     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
40     test(S(), 'a', S(1, 'a'));
41     test(S("12345"), 'a', S("12345a"));
42     test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
43     }
44 #endif
45 }
46