1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // XFAIL: LIBCXX-AIX-FIXME 10 11 // <string> 12 13 // void pop_back(); // constexpr since C++20 14 15 #include <string> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "min_allocator.h" 20 21 template <class S> 22 TEST_CONSTEXPR_CXX20 void 23 test(S s, S expected) 24 { 25 s.pop_back(); 26 LIBCPP_ASSERT(s.__invariants()); 27 assert(s[s.size()] == typename S::value_type()); 28 assert(s == expected); 29 } 30 31 TEST_CONSTEXPR_CXX20 bool test() { 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 return true; 48 } 49 50 int main(int, char**) 51 { 52 test(); 53 #if TEST_STD_VER > 17 54 static_assert(test()); 55 #endif 56 57 return 0; 58 } 59