blob: 455a0821f0efe5a759ca3f3b4f8305ee34f4dcce [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
Howard Hinnant6e0a1f42010-08-22 00:47:54 +000012// basic_string<charT,traits,Allocator>&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000013// operator=(basic_string<charT,traits,Allocator>&& str);
14
15#include <string>
16#include <cassert>
17
Howard Hinnant73d21a42010-09-04 23:28:19 +000018#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000019
20#include "../test_allocator.h"
21
22template <class S>
23void
24test(S s1, S s2)
25{
26 S s0 = s2;
27 s1 = std::move(s2);
28 assert(s1.__invariants());
29 assert(s2.__invariants());
30 assert(s1 == s0);
31 assert(s1.capacity() >= s1.size());
32}
33
Howard Hinnant73d21a42010-09-04 23:28:19 +000034#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000035
36int main()
37{
Howard Hinnant73d21a42010-09-04 23:28:19 +000038#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000039 typedef std::string S;
40 test(S(), S());
41 test(S("1"), S());
42 test(S(), S("1"));
43 test(S("1"), S("2"));
44 test(S("1"), S("2"));
45
46 test(S(),
47 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
48 test(S("123456789"),
49 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
50 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
51 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
52 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
53 "1234567890123456789012345678901234567890123456789012345678901234567890"),
54 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
Howard Hinnant73d21a42010-09-04 23:28:19 +000055#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000056}