• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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* copy(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     char8_t s2[3] = {0};
28     assert(std::char_traits<char8_t>::copy(s2, s1, 3) == s2);
29     assert(s2[0] == char8_t(1));
30     assert(s2[1] == char8_t(2));
31     assert(s2[2] == char8_t(3));
32     assert(std::char_traits<char8_t>::copy(NULL, s1, 0) == NULL);
33     assert(std::char_traits<char8_t>::copy(s1, NULL, 0) == s1);
34 #endif
35 
36   return true;
37 }
38 
main(int,char **)39 int main(int, char**)
40 {
41     test();
42 
43 #if TEST_STD_VER > 17
44     static_assert(test());
45 #endif
46 
47   return 0;
48 }
49