Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame^] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Eric Fiselier | 1f4231f | 2016-04-28 22:28:23 +0000 | [diff] [blame] | 9 | // UNSUPPORTED: c++98, c++03 |
| 10 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 11 | // <string> |
| 12 | |
| 13 | // basic_string(basic_string<charT,traits,Allocator>&& str); |
| 14 | |
| 15 | #include <string> |
| 16 | #include <cassert> |
| 17 | |
Eric Fiselier | 1f4231f | 2016-04-28 22:28:23 +0000 | [diff] [blame] | 18 | #include "test_macros.h" |
Marshall Clow | c3deeb5 | 2013-12-03 00:18:10 +0000 | [diff] [blame] | 19 | #include "test_allocator.h" |
Marshall Clow | e34f6f6 | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 20 | #include "min_allocator.h" |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
| 22 | template <class S> |
| 23 | void |
| 24 | test(S s0) |
| 25 | { |
| 26 | S s1 = s0; |
| 27 | S s2 = std::move(s0); |
Eric Fiselier | 1f4231f | 2016-04-28 22:28:23 +0000 | [diff] [blame] | 28 | LIBCPP_ASSERT(s2.__invariants()); |
| 29 | LIBCPP_ASSERT(s0.__invariants()); |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | assert(s2 == s1); |
| 31 | assert(s2.capacity() >= s2.size()); |
| 32 | assert(s2.get_allocator() == s1.get_allocator()); |
| 33 | } |
| 34 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 35 | int main() |
| 36 | { |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 37 | { |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 38 | typedef test_allocator<char> A; |
| 39 | typedef std::basic_string<char, std::char_traits<char>, A> S; |
| 40 | test(S(A(3))); |
| 41 | test(S("1", A(5))); |
| 42 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7))); |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 43 | } |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 44 | { |
| 45 | typedef min_allocator<char> A; |
| 46 | typedef std::basic_string<char, std::char_traits<char>, A> S; |
| 47 | test(S(A{})); |
| 48 | test(S("1", A())); |
| 49 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A())); |
| 50 | } |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 51 | } |