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 // explicit basic_string(const Allocator& a = Allocator());
13 
14 #include <string>
15 #include <cassert>
16 
17 #include "test_allocator.h"
18 #include "min_allocator.h"
19 
20 template <class S>
21 void
test()22 test()
23 {
24     {
25     S s;
26     assert(s.__invariants());
27     assert(s.data());
28     assert(s.size() == 0);
29     assert(s.capacity() >= s.size());
30     assert(s.get_allocator() == typename S::allocator_type());
31     }
32     {
33     S s(typename S::allocator_type(5));
34     assert(s.__invariants());
35     assert(s.data());
36     assert(s.size() == 0);
37     assert(s.capacity() >= s.size());
38     assert(s.get_allocator() == typename S::allocator_type(5));
39     }
40 }
41 
42 #if __cplusplus >= 201103L
43 
44 template <class S>
45 void
test2()46 test2()
47 {
48     {
49     S s;
50     assert(s.__invariants());
51     assert(s.data());
52     assert(s.size() == 0);
53     assert(s.capacity() >= s.size());
54     assert(s.get_allocator() == typename S::allocator_type());
55     }
56     {
57     S s(typename S::allocator_type{});
58     assert(s.__invariants());
59     assert(s.data());
60     assert(s.size() == 0);
61     assert(s.capacity() >= s.size());
62     assert(s.get_allocator() == typename S::allocator_type());
63     }
64 }
65 
66 #endif
67 
main()68 int main()
69 {
70     test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
71 #if __cplusplus >= 201103L
72     test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
73 #endif
74 }
75