| 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: executor-has-no-bash |
| 11 |
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME |
| 12 |
|
| 13 |
// FIXME PRINT How to test println on Windows? |
| 14 |
// XFAIL: msvc, target={{.+}}-windows-gnu |
| 15 |
|
| 16 |
// XFAIL: availability-fp_to_chars-missing |
| 17 |
|
| 18 |
// <print> |
| 19 |
|
| 20 |
// template<class... Args> |
| 21 |
// void println(format_string<Args...> fmt, Args&&... args); |
| 22 |
|
| 23 |
// Testing this properly is quite hard; the function unconditionally |
| 24 |
// writes to stdout. When stdout is redirected to a file it is no longer |
| 25 |
// considered a terminal. The function is a small wrapper around |
| 26 |
// |
| 27 |
// template<class... Args> |
| 28 |
// void println(FILE* stream, format_string<Args...> fmt, Args&&... args); |
| 29 |
// |
| 30 |
// So do minimal tests for this function and rely on the FILE* overload |
| 31 |
// to do more testing. |
| 32 |
// |
| 33 |
// The testing is based on the testing for std::cout. |
| 34 |
|
| 35 |
// TODO PRINT Use lit builtin echo |
| 36 |
|
| 37 |
// FILE_DEPENDENCIES: echo.sh |
| 38 |
// RUN: %{build} |
| 39 |
// RUN: %{exec} bash echo.sh -ne "1234 一二三四\ntrue 0x0\n" > %t.expected |
| 40 |
// RUN: %{exec} "%t.exe" > %t.actual |
| 41 |
// RUN: diff -u %t.actual %t.expected |
| 42 |
|
| 43 |
#include <print> |
| 44 |
|
| 45 |
int main(int, char**) { |
| 46 |
// The data is passed as-is so it does not depend on the encoding of the input. |
| 47 |
std::println("{} {}", 1234, "一二三四"); |
| 48 |
std::println("{} {}", true, nullptr); |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |