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 #if _LIBCPP_DEBUG >= 1 15 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) 16 #endif 17 18 #include <string> 19 #include <cassert> 20 21 #include "min_allocator.h" 22 23 template <class S> 24 void 25 test(S s, S expected) 26 { 27 s.pop_back(); 28 assert(s.__invariants()); 29 assert(s == expected); 30 } 31 32 int main() 33 { 34 { 35 typedef std::string S; 36 test(S("abcde"), S("abcd")); 37 test(S("abcdefghij"), S("abcdefghi")); 38 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); 39 } 40 #if __cplusplus >= 201103L 41 { 42 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 43 test(S("abcde"), S("abcd")); 44 test(S("abcdefghij"), S("abcdefghi")); 45 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); 46 } 47 #endif 48 #if _LIBCPP_DEBUG >= 1 49 { 50 std::string s; 51 s.pop_back(); 52 assert(false); 53 } 54 #endif 55 } 56