Debian Codegraph @

libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.sh.cpp

raw
1 //===----------------------------------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9 // UNSUPPORTED: no-filesystem
10 // UNSUPPORTED: libcpp-has-no-unicode
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
12
13 // XFAIL: availability-fp_to_chars-missing
14
15 // <print>
16
17 // void vprint_unicode(string_view fmt, format_args args);
18
19 // Testing this properly is quite hard; the function unconditionally
20 // writes to stdout. When stdout is redirected to a file it is no longer
21 // considered a terminal. The function is a small wrapper around
22 //
23 // void vprint_unicode(FILE* stream, string_view fmt, format_args args);
24 //
25 // So do minimal tests for this function and rely on the FILE* overload
26 // to do more testing.
27 //
28 // The testing is based on the testing for std::cout.
29
30 // RUN: %{build}
31 // RUN: echo -n "1234 一二三四 true 0x0" > %t.expected
32 // RUN: %{exec} %t.exe > %t.actual
33 // RUN: diff -u %t.actual %t.expected
34
35 #include <print>
36
37 int main(int, char**) {
38 // The data is passed as-is so it does not depend on the encoding of the input.
39 int i = 1234;
40 const char* s = "一二三四";
41 bool b = true;
42 nullptr_t p = nullptr;
43 std::vprint_unicode("{} {} ", std::make_format_args(i, s));
44 std::vprint_unicode("{} {}", std::make_format_args(b, p));
45
46 return 0;
47 }