49 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++17, c++2010// UNSUPPORTED: no-filesystem11// UNSUPPORTED: libcpp-has-no-unicode12// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME13 14// XFAIL: availability-fp_to_chars-missing15 16// <print>17 18// void vprint_unicode(string_view fmt, format_args args);19 20// Testing this properly is quite hard; the function unconditionally21// writes to stdout. When stdout is redirected to a file it is no longer22// considered a terminal. The function is a small wrapper around23//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* overload27// 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.expected33// RUN: %{exec} %t.exe > %t.actual34// RUN: diff -u %t.actual %t.expected35 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