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

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