Debian Codegraph @

libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar_t/assign3.pass.cpp

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