1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-exceptions
12 // size_type max_size() const;
14 // NOTE: asan and msan will fail for one of two reasons
15 // 1. If allocator_may_return_null=0 then they will fail because the allocation
17 // 2. If allocator_may_return_null=1 then they will fail because the allocation
18 // is too large to succeed.
19 // UNSUPPORTED: sanitizer-new-delete
24 #include "test_macros.h"
25 #include "min_allocator.h"
32 const size_t sz
= s2
.max_size() - 1;
33 try { s2
.resize(sz
, 'x'); }
34 catch ( const std::bad_alloc
& ) { return ; }
35 assert ( s2
.size() == sz
);
43 const size_t sz
= s2
.max_size();
44 try { s2
.resize(sz
, 'x'); }
45 catch ( const std::bad_alloc
& ) { return ; }
46 assert ( s
.size() == sz
);
53 assert(s
.max_size() >= s
.size());
61 typedef std::string S
;
64 test(S("12345678901234567890123456789012345678901234567890"));
66 #if TEST_STD_VER >= 11
68 typedef std::basic_string
<char, std::char_traits
<char>, min_allocator
<char>> S
;
71 test(S("12345678901234567890123456789012345678901234567890"));