blob: bbadb9ccc5a887b9346be67f2fad4014a197035a [file] [log] [blame]
Eric Fiselier1c3b15d2014-11-14 03:16:12 +00001//===----------------------------------------------------------------------===//
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
Eric Fiselier1c3b15d2014-11-14 03:16:12 +000010// <string>
11
12// size_type max_size() const;
13
14#include <string>
15#include <cassert>
16
17#include "min_allocator.h"
18
19template <class S>
20void
21test(const S& s)
22{
23 assert(s.max_size() >= s.size());
24 S s2(s);
25 const size_t sz = s2.max_size() + 1;
26 try { s2.resize(sz, 'x'); }
27 catch ( const std::length_error & ) { return ; }
28 assert ( false );
29}
30
31int main()
32{
33 {
34 typedef std::string S;
35 test(S());
36 test(S("123"));
37 test(S("12345678901234567890123456789012345678901234567890"));
38 }
39#if __cplusplus >= 201103L
40 {
41 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
42 test(S());
43 test(S("123"));
44 test(S("12345678901234567890123456789012345678901234567890"));
45 }
46#endif
47}