blob: 9ed244406d01823ef2432d983a8c36b8b1a1f3dd [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
Eric Fiselier1f4231f2016-04-28 22:28:23 +000010// UNSUPPORTED: c++98, c++03
11
Howard Hinnant3e519522010-05-11 19:42:16 +000012// <string>
13
14// basic_string(basic_string<charT,traits,Allocator>&& str);
15
16#include <string>
17#include <cassert>
18
Eric Fiselier1f4231f2016-04-28 22:28:23 +000019#include "test_macros.h"
Marshall Clowc3deeb52013-12-03 00:18:10 +000020#include "test_allocator.h"
Marshall Clowe34f6f62013-11-26 20:58:02 +000021#include "min_allocator.h"
Howard Hinnant3e519522010-05-11 19:42:16 +000022
23template <class S>
24void
25test(S s0)
26{
27 S s1 = s0;
28 S s2 = std::move(s0);
Eric Fiselier1f4231f2016-04-28 22:28:23 +000029 LIBCPP_ASSERT(s2.__invariants());
30 LIBCPP_ASSERT(s0.__invariants());
Howard Hinnant3e519522010-05-11 19:42:16 +000031 assert(s2 == s1);
32 assert(s2.capacity() >= s2.size());
33 assert(s2.get_allocator() == s1.get_allocator());
34}
35
Howard Hinnant3e519522010-05-11 19:42:16 +000036int main()
37{
Howard Hinnanteec72182013-06-28 16:59:19 +000038 {
Howard Hinnant3e519522010-05-11 19:42:16 +000039 typedef test_allocator<char> A;
40 typedef std::basic_string<char, std::char_traits<char>, A> S;
41 test(S(A(3)));
42 test(S("1", A(5)));
43 test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
Howard Hinnanteec72182013-06-28 16:59:19 +000044 }
Howard Hinnanteec72182013-06-28 16:59:19 +000045 {
46 typedef min_allocator<char> A;
47 typedef std::basic_string<char, std::char_traits<char>, A> S;
48 test(S(A{}));
49 test(S("1", A()));
50 test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
51 }
Howard Hinnant3e519522010-05-11 19:42:16 +000052}