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 == expected); 27 } 28 29 int main() 30 { 31 { 32 typedef std::string S; 33 test(S("abcde"), S("abcd")); 34 test(S("abcdefghij"), S("abcdefghi")); 35 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); 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("abcde"), S("abcd")); 41 test(S("abcdefghij"), S("abcdefghi")); 42 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); 43 } 44 #endif 45 } 46