brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 5618836 Raw
58 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-threads11 12// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME13 14// TODO FMT This test should not require std::to_chars(floating-point)15// XFAIL: availability-fp_to_chars-missing16 17// <thread>18 19// template<class charT>20// struct formatter<thread::id, charT>;21 22// template<class... Args>23//   string format(format_string<Args...> fmt, Args&&... args);24// template<class... Args>25//   wstring format(wformat_string<Args...> fmt, Args&&... args);26 27#include <format>28#include <cassert>29 30#include "assert_macros.h"31#include "concat_macros.h"32#include "format.functions.tests.h"33#include "test_format_string.h"34#include "test_macros.h"35 36auto test = []<class CharT, class... Args>(37                std::basic_string_view<CharT> expected, test_format_string<CharT, Args...> fmt, Args&&... args) {38  std::basic_string<CharT> out = std::format(fmt, std::forward<Args>(args)...);39  TEST_REQUIRE(out == expected,40               TEST_WRITE_CONCATENATED(41                   "\nFormat string   ", fmt, "\nExpected output ", expected, "\nActual output   ", out, '\n'));42};43 44auto test_exception = []<class CharT, class... Args>(std::string_view, std::basic_string_view<CharT>, Args&&...) {45  // After P2216 most exceptions thrown by std::format become ill-formed.46  // Therefore this tests does nothing.47};48 49int main(int, char**) {50  format_tests<char>(test, test_exception);51 52#ifndef TEST_HAS_NO_WIDE_CHARACTERS53  format_tests<wchar_t>(test, test_exception);54#endif55 56  return 0;57}58