2010-05-11 19:42:16 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
//
|
2019-01-19 10:56:40 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-11 19:42:16 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2020-06-01 10:38:23 -04:00
|
|
|
// UNSUPPORTED: c++03
|
2016-04-28 22:28:23 +00:00
|
|
|
|
2010-05-11 19:42:16 +00:00
|
|
|
// <string>
|
|
|
|
|
|
2010-08-22 00:47:54 +00:00
|
|
|
// basic_string<charT,traits,Allocator>&
|
2010-05-11 19:42:16 +00:00
|
|
|
// operator=(basic_string<charT,traits,Allocator>&& str);
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
2016-04-28 22:28:23 +00:00
|
|
|
#include "test_macros.h"
|
2013-12-03 00:18:10 +00:00
|
|
|
#include "test_allocator.h"
|
2013-11-26 20:58:02 +00:00
|
|
|
#include "min_allocator.h"
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
|
template <class S>
|
|
|
|
|
void
|
|
|
|
|
test(S s1, S s2)
|
|
|
|
|
{
|
|
|
|
|
S s0 = s2;
|
|
|
|
|
s1 = std::move(s2);
|
2016-04-28 22:28:23 +00:00
|
|
|
LIBCPP_ASSERT(s1.__invariants());
|
|
|
|
|
LIBCPP_ASSERT(s2.__invariants());
|
2010-05-11 19:42:16 +00:00
|
|
|
assert(s1 == s0);
|
|
|
|
|
assert(s1.capacity() >= s1.size());
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-04 20:31:13 +00:00
|
|
|
int main(int, char**)
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
2013-06-28 16:59:19 +00:00
|
|
|
{
|
2010-05-11 19:42:16 +00:00
|
|
|
typedef std::string S;
|
|
|
|
|
test(S(), S());
|
|
|
|
|
test(S("1"), S());
|
|
|
|
|
test(S(), S("1"));
|
|
|
|
|
test(S("1"), S("2"));
|
|
|
|
|
test(S("1"), S("2"));
|
|
|
|
|
|
|
|
|
|
test(S(),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
|
|
|
|
test(S("123456789"),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
|
|
|
|
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
|
|
|
|
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
|
|
|
|
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
2013-06-28 16:59:19 +00:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
|
|
|
|
test(S(), S());
|
|
|
|
|
test(S("1"), S());
|
|
|
|
|
test(S(), S("1"));
|
|
|
|
|
test(S("1"), S("2"));
|
|
|
|
|
test(S("1"), S("2"));
|
|
|
|
|
|
|
|
|
|
test(S(),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
|
|
|
|
test(S("123456789"),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
|
|
|
|
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
|
|
|
|
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
|
|
|
|
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
|
|
|
|
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
|
|
|
|
}
|
2019-02-04 20:31:13 +00:00
|
|
|
|
|
|
|
|
return 0;
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|