Debian Codegraph @

libcxx/test/std/containers/sequences/vector.bool/vector.bool.fmt/format.functions.format.pass.cpp

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