Debian Codegraph @

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