1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 // basic_string<charT,traits,Allocator>&
14 // operator=(basic_string<charT,traits,Allocator>&& str); // constexpr since C++20
19 #include "test_macros.h"
20 #include "asan_testing.h"
22 TEST_CONSTEXPR_CXX20
bool test() {
23 // Test that assignment from {} and {ptr, len} are allowed and are not
26 std::string s
= "hello world";
29 LIBCPP_ASSERT(is_string_asan_correct(s
));
32 std::string s
= "hello world";
35 LIBCPP_ASSERT(is_string_asan_correct(s
));
38 std::string s
= "hello world";
39 s
= {"It'sALongString!NoSSO!qwertyuiop", 30};
40 assert(s
== "It'sALongString!NoSSO!qwertyui");
41 LIBCPP_ASSERT(is_string_asan_correct(s
));
44 std::string s
= "Hello world! Hello world! Hello world! Hello world! Hello world!";
45 s
= {"It'sALongString!NoSSO!qwertyuiop", 30};
46 assert(s
== "It'sALongString!NoSSO!qwertyui");
47 LIBCPP_ASSERT(is_string_asan_correct(s
));
50 std::string s
= "Hello world! Hello world! Hello world! Hello world! Hello world!";
53 LIBCPP_ASSERT(is_string_asan_correct(s
));
56 std::string s
= "Hello world! Hello world! Hello world! Hello world! Hello world!";
59 LIBCPP_ASSERT(is_string_asan_correct(s
));
65 int main(int, char**) {
68 static_assert(test());