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// size_type capacity() const;
13
14#include <string>
15#include <cassert>
16
17#include "test_allocator.h"
18#include "min_allocator.h"
19
20template <class S>
21void
22test(S s)
23{
24    S::allocator_type::throw_after = 0;
25    try
26    {
27        while (s.size() < s.capacity())
28            s.push_back(typename S::value_type());
29        assert(s.size() == s.capacity());
30    }
31    catch (...)
32    {
33        assert(false);
34    }
35    S::allocator_type::throw_after = INT_MAX;
36}
37
38int main()
39{
40    {
41    typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S;
42    S s;
43    test(s);
44    s.assign(10, 'a');
45    s.erase(5);
46    test(s);
47    s.assign(100, 'a');
48    s.erase(50);
49    test(s);
50    }
51#if __cplusplus >= 201103L
52    {
53    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
54    S s;
55    assert(s.capacity() > 0);
56    }
57#endif
58}
59