[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.cons / brace_assignment.pass.cpp
blob49a90872c56faede921759f8d4770e06ddce481b
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 // <string>
13 // basic_string<charT,traits,Allocator>&
14 // operator=(basic_string<charT,traits,Allocator>&& str); // constexpr since C++20
16 #include <string>
17 #include <cassert>
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
24 // ambiguous.
26 std::string s = "hello world";
27 s = {};
28 assert(s.empty());
29 LIBCPP_ASSERT(is_string_asan_correct(s));
32 std::string s = "hello world";
33 s = {"abc", 2};
34 assert(s == "ab");
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!";
51 s = {"abc", 2};
52 assert(s == "ab");
53 LIBCPP_ASSERT(is_string_asan_correct(s));
56 std::string s = "Hello world! Hello world! Hello world! Hello world! Hello world!";
57 s = {"abc", 0};
58 assert(s == "");
59 LIBCPP_ASSERT(is_string_asan_correct(s));
62 return true;
65 int main(int, char**) {
66 test();
67 #if TEST_STD_VER > 17
68 static_assert(test());
69 #endif
71 return 0;