xref: /llvm-project/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.sh.cpp (revision 6a54dfbfe534276d644d7f9c027f0deeb748dd53)
1e2953303SMark de Wever //===----------------------------------------------------------------------===//
2*6a54dfbfSLouis Dionne //
3e2953303SMark de Wever // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e2953303SMark de Wever // See https://llvm.org/LICENSE.txt for license information.
5e2953303SMark de Wever // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e2953303SMark de Wever //
7e2953303SMark de Wever //===----------------------------------------------------------------------===//
8e2953303SMark de Wever 
9e2953303SMark de Wever // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
101cf970dbSKonstantin Varlamov // UNSUPPORTED: no-filesystem
11e2953303SMark de Wever // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
12e2953303SMark de Wever 
13e2953303SMark de Wever // XFAIL: availability-fp_to_chars-missing
14e2953303SMark de Wever 
15e2953303SMark de Wever // <print>
16e2953303SMark de Wever 
17e2953303SMark de Wever //  void vprint_nonunicode(string_view fmt, format_args args);
18e2953303SMark de Wever 
19e2953303SMark de Wever // Testing this properly is quite hard; the function unconditionally
20e2953303SMark de Wever // writes to stdout. When stdout is redirected to a file it is no longer
21e2953303SMark de Wever // considered a terminal. The function is a small wrapper around
22e2953303SMark de Wever //
23e2953303SMark de Wever //  void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
24e2953303SMark de Wever //
25e2953303SMark de Wever // So do minimal tests for this function and rely on the FILE* overload
26e2953303SMark de Wever // to do more testing.
27e2953303SMark de Wever //
28e2953303SMark de Wever // The testing is based on the testing for std::cout.
29e2953303SMark de Wever 
30e2953303SMark de Wever // RUN: %{build}
31257eb745SLouis Dionne // RUN: echo -n "1234 一二三四 true 0x0" > %t.expected
32257eb745SLouis Dionne // RUN: %{exec} %t.exe > %t.actual
33e2953303SMark de Wever // RUN: diff -u %t.actual %t.expected
34e2953303SMark de Wever 
35e2953303SMark de Wever #include <print>
36e2953303SMark de Wever 
37e2953303SMark de Wever int main(int, char**) {
38e2953303SMark de Wever   // The data is passed as-is so it does not depend on the encoding of the input.
39e3f154d8SMark de Wever   int i         = 1234;
40e3f154d8SMark de Wever   const char* s = "一二三四";
41e3f154d8SMark de Wever   bool b        = true;
42e3f154d8SMark de Wever   nullptr_t p   = nullptr;
43e3f154d8SMark de Wever   std::vprint_nonunicode("{} {} ", std::make_format_args(i, s));
44e3f154d8SMark de Wever   std::vprint_nonunicode("{} {}", std::make_format_args(b, p));
45e2953303SMark de Wever 
46e2953303SMark de Wever   return 0;
47e2953303SMark de Wever }
48