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: executor-has-no-bash 10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME 11 12 // XFAIL: availability-fp_to_chars-missing 13 14 // <print> 15 16 // template<class... Args> 17 // void print(format_string<Args...> fmt, 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 // template<class... Args> 24 // void print(FILE* stream, format_string<Args...> fmt, 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 // TODO PRINT Use lit builtin echo 32 33 // FILE_DEPENDENCIES: echo.sh 34 // RUN: %{build} 35 // RUN: %{exec} bash echo.sh -n "1234 一二三四 true 0x0" > %t.expected 36 // RUN: %{exec} "%t.exe" > %t.actual 37 // RUN: diff -u %t.actual %t.expected 38 39 #include <print> 40 41 int main(int, char**) { 42 // The data is passed as-is so it does not depend on the encoding of the input. 43 std::print("{} {} ", 1234, "一二三四"); 44 std::print("{} {}", true, nullptr); 45 46 return 0; 47 } 48