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 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: clang-8
11
12 // <string>
13
14 // template<> struct char_traits<char8_t>
15
16 // static char_type* assign(char_type* s, size_t n, char_type a);
17
18 #include <string>
19 #include <cassert>
20
21 #include "test_macros.h"
22
test()23 TEST_CONSTEXPR_CXX20 bool test()
24 {
25 #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
26 char8_t s2[3] = {0};
27 assert(std::char_traits<char8_t>::assign(s2, 3, char8_t(5)) == s2);
28 assert(s2[0] == char8_t(5));
29 assert(s2[1] == char8_t(5));
30 assert(s2[2] == char8_t(5));
31 assert(std::char_traits<char8_t>::assign(NULL, 0, char8_t(5)) == NULL);
32 #endif
33
34 return true;
35 }
36
main(int,char **)37 int main(int, char**)
38 {
39 test();
40
41 #if TEST_STD_VER > 17
42 static_assert(test());
43 #endif
44
45 return 0;
46 }
47