[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.cons / initializer_list.pass.cpp
blobebdcc523f055d4ab40177b94eb74de1f3e024631
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(initializer_list<charT> il, const Allocator& a = Allocator()); // constexpr since C++20
15 #include <string>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
21 #include "asan_testing.h"
23 // clang-format off
24 template <template <class> class Alloc>
25 TEST_CONSTEXPR_CXX20 void test_string() {
27 std::basic_string<char, std::char_traits<char>, Alloc<char> > s = {'a', 'b', 'c'};
28 assert(s == "abc");
29 LIBCPP_ASSERT(is_string_asan_correct(s));
32 std::basic_string<char, std::char_traits<char>, Alloc<char> > s = {'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'};
33 assert(s == "aaaaaaaaaaaaaaaaaaaaaaaaa");
34 LIBCPP_ASSERT(is_string_asan_correct(s));
36 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
38 std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> > s = {L'a', L'b', L'c'};
39 assert(s == L"abc");
40 LIBCPP_ASSERT(is_string_asan_correct(s));
43 std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> > s = {L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a', L'a'};
44 assert(s == L"aaaaaaaaaaaaaaaaaaaaaaaaa");
45 LIBCPP_ASSERT(is_string_asan_correct(s));
47 #endif
49 // clang-format on
51 TEST_CONSTEXPR_CXX20 bool test() {
52 test_string<std::allocator>();
53 test_string<min_allocator>();
54 test_string<safe_allocator>();
56 return true;
59 int main(int, char**) {
60 test();
61 #if TEST_STD_VER > 17
62 static_assert(test());
63 #endif
65 return 0;