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* move(char_type* s1, const char_type* s2, size_t n);
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 s1[] = {1, 2, 3};
27 assert(std::char_traits<char8_t>::move(s1, s1+1, 2) == s1);
28 assert(s1[0] == char8_t(2));
29 assert(s1[1] == char8_t(3));
30 assert(s1[2] == char8_t(3));
31 s1[2] = char8_t(0);
32 assert(std::char_traits<char8_t>::move(s1+1, s1, 2) == s1+1);
33 assert(s1[0] == char8_t(2));
34 assert(s1[1] == char8_t(2));
35 assert(s1[2] == char8_t(3));
36 assert(std::char_traits<char8_t>::move(NULL, s1, 0) == NULL);
37 assert(std::char_traits<char8_t>::move(s1, NULL, 0) == s1);
38 #endif
39
40 return true;
41 }
42
main(int,char **)43 int main(int, char**)
44 {
45 test();
46
47 #if TEST_STD_VER > 17
48 static_assert(test());
49 #endif
50
51 return 0;
52 }
53