brintos

brintos / llvm-project-archived public Read only

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