Home | History | Annotate | Download | only in string.cons
      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 // UNSUPPORTED: c++98, c++03
     11 
     12 // <string>
     13 
     14 // basic_string(basic_string<charT,traits,Allocator>&& str);
     15 
     16 #include <string>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 #include "test_allocator.h"
     21 #include "min_allocator.h"
     22 
     23 template <class S>
     24 void
     25 test(S s0)
     26 {
     27     S s1 = s0;
     28     S s2 = std::move(s0);
     29     LIBCPP_ASSERT(s2.__invariants());
     30     LIBCPP_ASSERT(s0.__invariants());
     31     assert(s2 == s1);
     32     assert(s2.capacity() >= s2.size());
     33     assert(s2.get_allocator() == s1.get_allocator());
     34 }
     35 
     36 int main()
     37 {
     38     {
     39     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)));
     44     }
     45     {
     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     }
     52 }
     53