blob: fb6001f85b605e53b1d81e8a44bea9ccd18531a8 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// basic_string(const basic_string<charT,traits,Allocator>& str);
13
14#include <string>
15#include <cassert>
16
17#include "../test_allocator.h"
Marshall Clowe34f6f62013-11-26 20:58:02 +000018#include "min_allocator.h"
Howard Hinnant3e519522010-05-11 19:42:16 +000019
20template <class S>
21void
22test(S s1)
23{
24 S s2 = s1;
25 assert(s2.__invariants());
26 assert(s2 == s1);
27 assert(s2.capacity() >= s2.size());
28 assert(s2.get_allocator() == s1.get_allocator());
29}
30
31int main()
32{
Howard Hinnanteec72182013-06-28 16:59:19 +000033 {
Howard Hinnant3e519522010-05-11 19:42:16 +000034 typedef test_allocator<char> A;
35 typedef std::basic_string<char, std::char_traits<char>, A> S;
36 test(S(A(3)));
37 test(S("1", A(5)));
38 test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
Howard Hinnanteec72182013-06-28 16:59:19 +000039 }
40#if __cplusplus >= 201103L
41 {
42 typedef min_allocator<char> A;
43 typedef std::basic_string<char, std::char_traits<char>, A> S;
44 test(S(A{}));
45 test(S("1", A()));
46 test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
47 }
48#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000049}