[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.capacity / over_max_size.pass.cpp
blob9271f3ce283e158b447ea70979ad943fe015d5a4
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-exceptions
10 // XFAIL: with_system_cxx_lib=macosx10.11
11 // XFAIL: with_system_cxx_lib=macosx10.10
12 // XFAIL: with_system_cxx_lib=macosx10.9
14 // <string>
16 // size_type max_size() const;
18 #include <string>
19 #include <cassert>
20 #include <stdexcept>
22 #include "test_macros.h"
23 #include "min_allocator.h"
25 template <class S>
26 void
27 test(const S& s)
29 assert(s.max_size() >= s.size());
30 S s2(s);
31 const size_t sz = s2.max_size() + 1;
32 try { s2.resize(sz, 'x'); }
33 catch ( const std::length_error & ) { return ; }
34 assert ( false );
37 int main(int, char**)
40 typedef std::string S;
41 test(S());
42 test(S("123"));
43 test(S("12345678901234567890123456789012345678901234567890"));
45 #if TEST_STD_VER >= 11
47 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
48 test(S());
49 test(S("123"));
50 test(S("12345678901234567890123456789012345678901234567890"));
52 #endif
54 return 0;