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