Home | History | Annotate | Download | only in string_erase
      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 pop_back();
     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
     22 test(S s, S expected)
     23 {
     24     s.pop_back();
     25     LIBCPP_ASSERT(s.__invariants());
     26     assert(s[s.size()] == typename S::value_type());
     27     assert(s == expected);
     28 }
     29 
     30 int main()
     31 {
     32     {
     33     typedef std::string S;
     34     test(S("abcde"), S("abcd"));
     35     test(S("abcdefghij"), S("abcdefghi"));
     36     test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
     37     }
     38 #if TEST_STD_VER >= 11
     39     {
     40     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
     41     test(S("abcde"), S("abcd"));
     42     test(S("abcdefghij"), S("abcdefghi"));
     43     test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
     44     }
     45 #endif
     46 }
     47