[libcxx-commits] [libcxx] ff8a476 - [libc++][nfc] Update formatting of some tests.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 25 11:01:45 PST 2022
Author: Mark de Wever
Date: 2022-01-25T20:01:32+01:00
New Revision: ff8a4766ac256e3361ef66c0765ef5b041f4dd5f
URL: https://github.com/llvm/llvm-project/commit/ff8a4766ac256e3361ef66c0765ef5b041f4dd5f
DIFF: https://github.com/llvm/llvm-project/commit/ff8a4766ac256e3361ef66c0765ef5b041f4dd5f.diff
LOG: [libc++][nfc] Update formatting of some tests.
These tests were formatted with older clang-format settings, this
updates them to the current settings.
In order to implement P2216 a lot of changes to these tests are
required. This makes it easier to review those patches.
Added:
Modified:
libcxx/test/std/utilities/format/format.functions/format.locale.pass.cpp
libcxx/test/std/utilities/format/format.functions/format.pass.cpp
libcxx/test/std/utilities/format/format.functions/format_tests.h
libcxx/test/std/utilities/format/format.functions/format_to.locale.pass.cpp
libcxx/test/std/utilities/format/format.functions/format_to.pass.cpp
libcxx/test/std/utilities/format/format.functions/format_to_n.locale.pass.cpp
libcxx/test/std/utilities/format/format.functions/format_to_n.pass.cpp
libcxx/test/std/utilities/format/format.functions/formatted_size.locale.pass.cpp
libcxx/test/std/utilities/format/format.functions/formatted_size.pass.cpp
libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/utilities/format/format.functions/format.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format.locale.pass.cpp
index 4da2f2ec6ee7f..197fddaa265f6 100644
--- a/libcxx/test/std/utilities/format/format.functions/format.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format.locale.pass.cpp
@@ -27,33 +27,31 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
std::basic_string<CharT> out = std::format(std::locale(), fmt, args...);
if constexpr (std::same_as<CharT, char>)
if (out != expected)
- std::cerr << "\nFormat string " << fmt << "\nExpected output "
- << expected << "\nActual output " << out << '\n';
+ std::cerr << "\nFormat string " << fmt << "\nExpected output " << expected << "\nActual output " << out
+ << '\n';
assert(out == expected);
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::format(std::locale(), fmt, args...);
if constexpr (std::same_as<CharT, char>)
- std::cerr << "\nFormat string " << fmt
- << "\nDidn't throw an exception.\n";
+ std::cerr << "\nFormat string " << fmt << "\nDidn't throw an exception.\n";
assert(false);
} catch (std::format_error& e) {
-#ifdef _LIBCPP_VERSION
+# ifdef _LIBCPP_VERSION
if constexpr (std::same_as<CharT, char>)
if (e.what() != what)
- std::cerr << "\nFormat string " << fmt << "\nExpected exception "
- << what << "\nActual exception " << e.what() << '\n';
-#endif
+ std::cerr << "\nFormat string " << fmt << "\nExpected exception " << what << "\nActual exception "
+ << e.what() << '\n';
+# endif
LIBCPP_ASSERT(e.what() == what);
return;
}
diff --git a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp
index 7963b1500f1c5..cf566670501bf 100644
--- a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp
@@ -25,44 +25,42 @@
#include <format>
#include <cassert>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#include <iostream>
+# include <iostream>
#endif
#include <vector>
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
std::basic_string<CharT> out = std::format(fmt, args...);
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
if constexpr (std::same_as<CharT, char>)
if (out != expected)
- std::cerr << "\nFormat string " << fmt << "\nExpected output "
- << expected << "\nActual output " << out << '\n';
+ std::cerr << "\nFormat string " << fmt << "\nExpected output " << expected << "\nActual output " << out
+ << '\n';
#endif
assert(out == expected);
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::format(fmt, args...);
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
if constexpr (std::same_as<CharT, char>)
- std::cerr << "\nFormat string " << fmt
- << "\nDidn't throw an exception.\n";
-#endif
+ std::cerr << "\nFormat string " << fmt << "\nDidn't throw an exception.\n";
+# endif
assert(false);
} catch (std::format_error& e) {
-#if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
if constexpr (std::same_as<CharT, char>)
if (e.what() != what)
- std::cerr << "\nFormat string " << fmt << "\nExpected exception "
- << what << "\nActual exception " << e.what() << '\n';
-#endif
+ std::cerr << "\nFormat string " << fmt << "\nExpected exception " << what << "\nActual exception "
+ << e.what() << '\n';
+# endif
LIBCPP_ASSERT(e.what() == what);
return;
}
diff --git a/libcxx/test/std/utilities/format/format.functions/format_tests.h b/libcxx/test/std/utilities/format/format.functions/format_tests.h
index 8deed4da43635..3b2d0c71f11cb 100644
--- a/libcxx/test/std/utilities/format/format.functions/format_tests.h
+++ b/libcxx/test/std/utilities/format/format.functions/format_tests.h
@@ -134,10 +134,10 @@ template <class CharT>
std::vector<std::basic_string<CharT>> invalid_types(std::string valid) {
std::vector<std::basic_string<CharT>> result;
-#define CASE(T) \
- case #T[0]: \
- result.push_back(STR("Invalid formatter type {:" #T "}")); \
- break;
+#define CASE(T) \
+case #T[0]: \
+ result.push_back(STR("Invalid formatter type {:" #T "}")); \
+ break;
for (auto type : "aAbBcdeEfFgGopsxX") {
if (valid.find(type) != std::string::npos)
@@ -173,18 +173,15 @@ std::vector<std::basic_string<CharT>> invalid_types(std::string valid) {
}
template <class CharT, class T, class TestFunction, class ExceptionTest>
-void format_test_string(T world, T universe, TestFunction check,
- ExceptionTest check_exception) {
+void format_test_string(T world, T universe, TestFunction check, ExceptionTest check_exception) {
// *** Valid input tests ***
// Unsed argument is ignored. TODO FMT what does the Standard mandate?
check(STR("hello world"), STR("hello {}"), world, universe);
- check(STR("hello world and universe"), STR("hello {} and {}"), world,
- universe);
+ check(STR("hello world and universe"), STR("hello {} and {}"), world, universe);
check(STR("hello world"), STR("hello {0}"), world, universe);
check(STR("hello universe"), STR("hello {1}"), world, universe);
- check(STR("hello universe and world"), STR("hello {1} and {0}"), world,
- universe);
+ check(STR("hello universe and world"), STR("hello {1} and {0}"), world, universe);
check(STR("hello world"), STR("hello {:_>}"), world);
check(STR("hello world"), STR("hello {:>8}"), world);
@@ -225,97 +222,69 @@ void format_test_string(T world, T universe, TestFunction check,
check(STR("hello uni#####"), STR("hello {:#<8.3s}"), universe);
// *** sign ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("hello {:-}"), world);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("hello {:-}"), world);
// *** alternate form ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("hello {:#}"), world);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("hello {:#}"), world);
// *** zero-padding ***
- check_exception("A format-spec width field shouldn't have a leading zero",
- STR("hello {:0}"), world);
+ check_exception("A format-spec width field shouldn't have a leading zero", STR("hello {:0}"), world);
// *** width ***
#ifdef _LIBCPP_VERSION
// This limit isn't specified in the Standard.
- static_assert(std::__format::__number_max == 2'147'483'647,
- "Update the assert and the test.");
- check_exception("The numeric value of the format-spec is too large",
- STR("{:2147483648}"), world);
- check_exception("The numeric value of the format-spec is too large",
- STR("{:5000000000}"), world);
- check_exception("The numeric value of the format-spec is too large",
- STR("{:10000000000}"), world);
+ static_assert(std::__format::__number_max == 2'147'483'647, "Update the assert and the test.");
+ check_exception("The numeric value of the format-spec is too large", STR("{:2147483648}"), world);
+ check_exception("The numeric value of the format-spec is too large", STR("{:5000000000}"), world);
+ check_exception("The numeric value of the format-spec is too large", STR("{:10000000000}"), world);
#endif
- check_exception(
- "A format-spec width field replacement should have a positive value",
- STR("hello {:{}}"), world, 0);
- check_exception(
- "A format-spec arg-id replacement shouldn't have a negative value",
- STR("hello {:{}}"), world, -1);
- check_exception(
- "A format-spec arg-id replacement exceeds the maximum supported value",
- STR("hello {:{}}"), world, unsigned(-1));
+ check_exception("A format-spec width field replacement should have a positive value", STR("hello {:{}}"), world, 0);
+ check_exception("A format-spec arg-id replacement shouldn't have a negative value", STR("hello {:{}}"), world, -1);
+ check_exception("A format-spec arg-id replacement exceeds the maximum supported value", STR("hello {:{}}"), world,
+ unsigned(-1));
check_exception("Argument index out of bounds", STR("hello {:{}}"), world);
- check_exception(
- "A format-spec arg-id replacement argument isn't an integral type",
- STR("hello {:{}}"), world, universe);
- check_exception(
- "Using manual argument numbering in automatic argument numbering mode",
- STR("hello {:{0}}"), world, 1);
- check_exception(
- "Using automatic argument numbering in manual argument numbering mode",
- STR("hello {0:{}}"), world, 1);
+ check_exception("A format-spec arg-id replacement argument isn't an integral type", STR("hello {:{}}"), world,
+ universe);
+ check_exception("Using manual argument numbering in automatic argument numbering mode", STR("hello {:{0}}"), world,
+ 1);
+ check_exception("Using automatic argument numbering in manual argument numbering mode", STR("hello {0:{}}"), world,
+ 1);
// Arg-id may not have leading zeros.
check_exception("Invalid arg-id", STR("hello {0:{01}}"), world, 1);
// *** precision ***
#ifdef _LIBCPP_VERSION
// This limit isn't specified in the Standard.
- static_assert(std::__format::__number_max == 2'147'483'647,
- "Update the assert and the test.");
- check_exception("The numeric value of the format-spec is too large",
- STR("{:.2147483648}"), world);
- check_exception("The numeric value of the format-spec is too large",
- STR("{:.5000000000}"), world);
- check_exception("The numeric value of the format-spec is too large",
- STR("{:.10000000000}"), world);
+ static_assert(std::__format::__number_max == 2'147'483'647, "Update the assert and the test.");
+ check_exception("The numeric value of the format-spec is too large", STR("{:.2147483648}"), world);
+ check_exception("The numeric value of the format-spec is too large", STR("{:.5000000000}"), world);
+ check_exception("The numeric value of the format-spec is too large", STR("{:.10000000000}"), world);
#endif
// Precision 0 allowed, but not useful for string arguments.
check(STR("hello "), STR("hello {:.{}}"), world, 0);
// Precision may have leading zeros. Secondly tests the value is still base 10.
check(STR("hello 0123456789"), STR("hello {:.000010}"), STR("0123456789abcdef"));
- check_exception(
- "A format-spec arg-id replacement shouldn't have a negative value",
- STR("hello {:.{}}"), world, -1);
- check_exception(
- "A format-spec arg-id replacement exceeds the maximum supported value",
- STR("hello {:.{}}"), world, ~0u);
+ check_exception("A format-spec arg-id replacement shouldn't have a negative value", STR("hello {:.{}}"), world, -1);
+ check_exception("A format-spec arg-id replacement exceeds the maximum supported value", STR("hello {:.{}}"), world,
+ ~0u);
check_exception("Argument index out of bounds", STR("hello {:.{}}"), world);
- check_exception(
- "A format-spec arg-id replacement argument isn't an integral type",
- STR("hello {:.{}}"), world, universe);
- check_exception(
- "Using manual argument numbering in automatic argument numbering mode",
- STR("hello {:.{0}}"), world, 1);
- check_exception(
- "Using automatic argument numbering in manual argument numbering mode",
- STR("hello {0:.{}}"), world, 1);
+ check_exception("A format-spec arg-id replacement argument isn't an integral type", STR("hello {:.{}}"), world,
+ universe);
+ check_exception("Using manual argument numbering in automatic argument numbering mode", STR("hello {:.{0}}"), world,
+ 1);
+ check_exception("Using automatic argument numbering in manual argument numbering mode", STR("hello {0:.{}}"), world,
+ 1);
// Arg-id may not have leading zeros.
check_exception("Invalid arg-id", STR("hello {0:.{01}}"), world, 1);
// *** locale-specific form ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("hello {:L}"), world);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("hello {:L}"), world);
// *** type ***
for (const auto& fmt : invalid_types<CharT>("s"))
- check_exception(
- "The format-spec type has a type not supported for a string argument",
- fmt, world);
+ check_exception("The format-spec type has a type not supported for a string argument", fmt, world);
}
template <class CharT, class TestFunction>
@@ -364,13 +333,10 @@ void format_string_tests(TestFunction check, ExceptionTest check_exception) {
// Testing the char const[] is a bit tricky due to array to pointer decay.
// Since there are separate tests in format.formatter.spec the array is not
// tested here.
- format_test_string<CharT>(world.c_str(), universe.c_str(), check,
+ format_test_string<CharT>(world.c_str(), universe.c_str(), check, check_exception);
+ format_test_string<CharT>(const_cast<CharT*>(world.c_str()), const_cast<CharT*>(universe.c_str()), check,
check_exception);
- format_test_string<CharT>(const_cast<CharT*>(world.c_str()),
- const_cast<CharT*>(universe.c_str()), check,
- check_exception);
- format_test_string<CharT>(std::basic_string_view<CharT>(world),
- std::basic_string_view<CharT>(universe), check,
+ format_test_string<CharT>(std::basic_string_view<CharT>(world), std::basic_string_view<CharT>(universe), check,
check_exception);
format_test_string<CharT>(world, universe, check, check_exception);
format_test_string_unicode<CharT>(check);
@@ -399,60 +365,41 @@ void format_test_bool(TestFunction check, ExceptionTest check_exception) {
check(STR("answer is '-false--'"), STR("answer is '{:-^8s}'"), false);
// *** Sign ***
- check_exception("A sign field isn't allowed in this format-spec", STR("{:-}"),
- true);
- check_exception("A sign field isn't allowed in this format-spec", STR("{:+}"),
- true);
- check_exception("A sign field isn't allowed in this format-spec", STR("{: }"),
- true);
-
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{:-s}"), true);
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{:+s}"), true);
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{: s}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:-}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:+}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{: }"), true);
+
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:-s}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:+s}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{: s}"), true);
// *** alternate form ***
- check_exception("An alternate form field isn't allowed in this format-spec",
- STR("{:#}"), true);
- check_exception("An alternate form field isn't allowed in this format-spec",
- STR("{:#s}"), true);
+ check_exception("An alternate form field isn't allowed in this format-spec", STR("{:#}"), true);
+ check_exception("An alternate form field isn't allowed in this format-spec", STR("{:#s}"), true);
// *** zero-padding ***
- check_exception("A zero-padding field isn't allowed in this format-spec",
- STR("{:0}"), true);
- check_exception("A zero-padding field isn't allowed in this format-spec",
- STR("{:0s}"), true);
+ check_exception("A zero-padding field isn't allowed in this format-spec", STR("{:0}"), true);
+ check_exception("A zero-padding field isn't allowed in this format-spec", STR("{:0s}"), true);
// *** precision ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42}"), true);
-
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.s}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0s}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42s}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42}"), true);
+
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.s}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0s}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42s}"), true);
// *** locale-specific form ***
// See locale-specific_form.pass.cpp
// *** type ***
for (const auto& fmt : invalid_types<CharT>("bBcdosxX"))
- check_exception(
- "The format-spec type has a type not supported for a bool argument",
- fmt, true);
+ check_exception("The format-spec type has a type not supported for a bool argument", fmt, true);
}
template <class CharT, class TestFunction, class ExceptionTest>
-void format_test_bool_as_char(TestFunction check,
- ExceptionTest check_exception) {
+void format_test_bool_as_char(TestFunction check, ExceptionTest check_exception) {
// *** align-fill & width ***
check(STR("answer is '\1 '"), STR("answer is '{:6c}'"), true);
check(STR("answer is ' \1'"), STR("answer is '{:>6c}'"), true);
@@ -463,47 +410,31 @@ void format_test_bool_as_char(TestFunction check,
check(STR("answer is '\1-----'"), STR("answer is '{:-<6c}'"), true);
check(STR("answer is '--\1---'"), STR("answer is '{:-^6c}'"), true);
- check(std::basic_string<CharT>(CSTR("answer is '\0 '"), 18),
- STR("answer is '{:6c}'"), false);
- check(std::basic_string<CharT>(CSTR("answer is '\0 '"), 18),
- STR("answer is '{:6c}'"), false);
- check(std::basic_string<CharT>(CSTR("answer is ' \0'"), 18),
- STR("answer is '{:>6c}'"), false);
- check(std::basic_string<CharT>(CSTR("answer is '\0 '"), 18),
- STR("answer is '{:<6c}'"), false);
- check(std::basic_string<CharT>(CSTR("answer is ' \0 '"), 18),
- STR("answer is '{:^6c}'"), false);
-
- check(std::basic_string<CharT>(CSTR("answer is '-----\0'"), 18),
- STR("answer is '{:->6c}'"), false);
- check(std::basic_string<CharT>(CSTR("answer is '\0-----'"), 18),
- STR("answer is '{:-<6c}'"), false);
- check(std::basic_string<CharT>(CSTR("answer is '--\0---'"), 18),
- STR("answer is '{:-^6c}'"), false);
+ check(std::basic_string<CharT>(CSTR("answer is '\0 '"), 18), STR("answer is '{:6c}'"), false);
+ check(std::basic_string<CharT>(CSTR("answer is '\0 '"), 18), STR("answer is '{:6c}'"), false);
+ check(std::basic_string<CharT>(CSTR("answer is ' \0'"), 18), STR("answer is '{:>6c}'"), false);
+ check(std::basic_string<CharT>(CSTR("answer is '\0 '"), 18), STR("answer is '{:<6c}'"), false);
+ check(std::basic_string<CharT>(CSTR("answer is ' \0 '"), 18), STR("answer is '{:^6c}'"), false);
+
+ check(std::basic_string<CharT>(CSTR("answer is '-----\0'"), 18), STR("answer is '{:->6c}'"), false);
+ check(std::basic_string<CharT>(CSTR("answer is '\0-----'"), 18), STR("answer is '{:-<6c}'"), false);
+ check(std::basic_string<CharT>(CSTR("answer is '--\0---'"), 18), STR("answer is '{:-^6c}'"), false);
// *** Sign ***
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{:-c}"), true);
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{:+c}"), true);
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{: c}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:-c}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:+c}"), true);
+ check_exception("A sign field isn't allowed in this format-spec", STR("{: c}"), true);
// *** alternate form ***
- check_exception("An alternate form field isn't allowed in this format-spec",
- STR("{:#c}"), true);
+ check_exception("An alternate form field isn't allowed in this format-spec", STR("{:#c}"), true);
// *** zero-padding ***
- check_exception("A zero-padding field isn't allowed in this format-spec",
- STR("{:0c}"), true);
+ check_exception("A zero-padding field isn't allowed in this format-spec", STR("{:0c}"), true);
// *** precision ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.c}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0c}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42c}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.c}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0c}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42c}"), true);
// *** locale-specific form ***
// Note it has no effect but it's allowed.
@@ -511,14 +442,11 @@ void format_test_bool_as_char(TestFunction check,
// *** type ***
for (const auto& fmt : invalid_types<CharT>("bBcdosxX"))
- check_exception(
- "The format-spec type has a type not supported for a bool argument",
- fmt, true);
+ check_exception("The format-spec type has a type not supported for a bool argument", fmt, true);
}
template <class CharT, class TestFunction, class ExceptionTest>
-void format_test_bool_as_integer(TestFunction check,
- ExceptionTest check_exception) {
+void format_test_bool_as_integer(TestFunction check, ExceptionTest check_exception) {
// *** align-fill & width ***
check(STR("answer is '1'"), STR("answer is '{:<1d}'"), true);
check(STR("answer is '1 '"), STR("answer is '{:<2d}'"), true);
@@ -591,26 +519,20 @@ void format_test_bool_as_integer(TestFunction check,
check(STR("answer is 0X0000000000"), STR("answer is {:#012X}"), false);
// *** precision ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0}"), true);
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0}"), true);
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42}"), true);
// *** locale-specific form ***
// See locale-specific_form.pass.cpp
// *** type ***
for (const auto& fmt : invalid_types<CharT>("bBcdosxX"))
- check_exception(
- "The format-spec type has a type not supported for a bool argument",
- fmt, true);
+ check_exception("The format-spec type has a type not supported for a bool argument", fmt, true);
}
template <class I, class CharT, class TestFunction, class ExceptionTest>
-void format_test_integer_as_integer(TestFunction check,
- ExceptionTest check_exception) {
+void format_test_integer_as_integer(TestFunction check, ExceptionTest check_exception) {
// *** align-fill & width ***
check(STR("answer is '42'"), STR("answer is '{:<1}'"), I(42));
check(STR("answer is '42'"), STR("answer is '{:<2}'"), I(42));
@@ -729,26 +651,20 @@ void format_test_integer_as_integer(TestFunction check,
check(STR("answer is +0X00000002A"), STR("answer is {:+#012X}"), I(42));
// *** precision ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.}"), I(0));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0}"), I(0));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42}"), I(0));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.}"), I(0));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0}"), I(0));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42}"), I(0));
// *** locale-specific form ***
// See locale-specific_form.pass.cpp
// *** type ***
for (const auto& fmt : invalid_types<CharT>("bBcdoxX"))
- check_exception(
- "The format-spec type has a type not supported for an integer argument",
- fmt, 42);
+ check_exception("The format-spec type has a type not supported for an integer argument", fmt, 42);
}
template <class I, class CharT, class TestFunction, class ExceptionTest>
-void format_test_integer_as_char(TestFunction check,
- ExceptionTest check_exception) {
+void format_test_integer_as_char(TestFunction check, ExceptionTest check_exception) {
// *** align-fill & width ***
check(STR("answer is '* '"), STR("answer is '{:6c}'"), I(42));
check(STR("answer is ' *'"), STR("answer is '{:>6c}'"), I(42));
@@ -761,28 +677,20 @@ void format_test_integer_as_char(TestFunction check,
// *** Sign ***
check(STR("answer is *"), STR("answer is {:c}"), I(42));
- check_exception("A sign field isn't allowed in this format-spec",
- STR("answer is {:-c}"), I(42));
- check_exception("A sign field isn't allowed in this format-spec",
- STR("answer is {:+c}"), I(42));
- check_exception("A sign field isn't allowed in this format-spec",
- STR("answer is {: c}"), I(42));
+ check_exception("A sign field isn't allowed in this format-spec", STR("answer is {:-c}"), I(42));
+ check_exception("A sign field isn't allowed in this format-spec", STR("answer is {:+c}"), I(42));
+ check_exception("A sign field isn't allowed in this format-spec", STR("answer is {: c}"), I(42));
// *** alternate form ***
- check_exception("An alternate form field isn't allowed in this format-spec",
- STR("answer is {:#c}"), I(42));
+ check_exception("An alternate form field isn't allowed in this format-spec", STR("answer is {:#c}"), I(42));
// *** zero-padding & width ***
- check_exception("A zero-padding field isn't allowed in this format-spec",
- STR("answer is {:01c}"), I(42));
+ check_exception("A zero-padding field isn't allowed in this format-spec", STR("answer is {:01c}"), I(42));
// *** precision ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.c}"), I(0));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0c}"), I(0));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42c}"), I(0));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.c}"), I(0));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0c}"), I(0));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42c}"), I(0));
// *** locale-specific form ***
// Note it has no effect but it's allowed.
@@ -790,9 +698,7 @@ void format_test_integer_as_char(TestFunction check,
// *** type ***
for (const auto& fmt : invalid_types<CharT>("bBcdoxX"))
- check_exception(
- "The format-spec type has a type not supported for an integer argument",
- fmt, I(42));
+ check_exception("The format-spec type has a type not supported for an integer argument", fmt, I(42));
// *** Validate range ***
// TODO FMT Update test after adding 128-bit support.
@@ -800,18 +706,16 @@ void format_test_integer_as_char(TestFunction check,
// The code has some duplications to keep the if statement readable.
if constexpr (std::signed_integral<CharT>) {
if constexpr (std::signed_integral<I> && sizeof(I) > sizeof(CharT)) {
- check_exception("Integral value outside the range of the char type",
- STR("{:c}"), std::numeric_limits<I>::min());
- check_exception("Integral value outside the range of the char type",
- STR("{:c}"), std::numeric_limits<I>::max());
- } else if constexpr (std::unsigned_integral<I> &&
- sizeof(I) >= sizeof(CharT)) {
- check_exception("Integral value outside the range of the char type",
- STR("{:c}"), std::numeric_limits<I>::max());
+ check_exception("Integral value outside the range of the char type", STR("{:c}"),
+ std::numeric_limits<I>::min());
+ check_exception("Integral value outside the range of the char type", STR("{:c}"),
+ std::numeric_limits<I>::max());
+ } else if constexpr (std::unsigned_integral<I> && sizeof(I) >= sizeof(CharT)) {
+ check_exception("Integral value outside the range of the char type", STR("{:c}"),
+ std::numeric_limits<I>::max());
}
} else if constexpr (sizeof(I) > sizeof(CharT)) {
- check_exception("Integral value outside the range of the char type",
- STR("{:c}"), std::numeric_limits<I>::max());
+ check_exception("Integral value outside the range of the char type", STR("{:c}"), std::numeric_limits<I>::max());
}
}
}
@@ -823,8 +727,7 @@ void format_test_integer(TestFunction check, ExceptionTest check_exception) {
}
template <class CharT, class TestFunction, class ExceptionTest>
-void format_test_signed_integer(TestFunction check,
- ExceptionTest check_exception) {
+void format_test_signed_integer(TestFunction check, ExceptionTest check_exception) {
format_test_integer<signed char, CharT>(check, check_exception);
format_test_integer<short, CharT>(check, check_exception);
format_test_integer<int, CharT>(check, check_exception);
@@ -839,62 +742,49 @@ void format_test_signed_integer(TestFunction check,
check(STR("-128"), STR("{:#}"), std::numeric_limits<int8_t>::min());
check(STR("-0x80"), STR("{:#x}"), std::numeric_limits<int8_t>::min());
- check(STR("-0b1000000000000000"), STR("{:#b}"),
- std::numeric_limits<int16_t>::min());
+ check(STR("-0b1000000000000000"), STR("{:#b}"), std::numeric_limits<int16_t>::min());
check(STR("-0100000"), STR("{:#o}"), std::numeric_limits<int16_t>::min());
check(STR("-32768"), STR("{:#}"), std::numeric_limits<int16_t>::min());
check(STR("-0x8000"), STR("{:#x}"), std::numeric_limits<int16_t>::min());
- check(STR("-0b10000000000000000000000000000000"), STR("{:#b}"),
- std::numeric_limits<int32_t>::min());
- check(STR("-020000000000"), STR("{:#o}"),
- std::numeric_limits<int32_t>::min());
+ check(STR("-0b10000000000000000000000000000000"), STR("{:#b}"), std::numeric_limits<int32_t>::min());
+ check(STR("-020000000000"), STR("{:#o}"), std::numeric_limits<int32_t>::min());
check(STR("-2147483648"), STR("{:#}"), std::numeric_limits<int32_t>::min());
check(STR("-0x80000000"), STR("{:#x}"), std::numeric_limits<int32_t>::min());
check(STR("-0b100000000000000000000000000000000000000000000000000000000000000"
"0"),
STR("{:#b}"), std::numeric_limits<int64_t>::min());
- check(STR("-01000000000000000000000"), STR("{:#o}"),
- std::numeric_limits<int64_t>::min());
- check(STR("-9223372036854775808"), STR("{:#}"),
- std::numeric_limits<int64_t>::min());
- check(STR("-0x8000000000000000"), STR("{:#x}"),
- std::numeric_limits<int64_t>::min());
+ check(STR("-01000000000000000000000"), STR("{:#o}"), std::numeric_limits<int64_t>::min());
+ check(STR("-9223372036854775808"), STR("{:#}"), std::numeric_limits<int64_t>::min());
+ check(STR("-0x8000000000000000"), STR("{:#x}"), std::numeric_limits<int64_t>::min());
check(STR("0b1111111"), STR("{:#b}"), std::numeric_limits<int8_t>::max());
check(STR("0177"), STR("{:#o}"), std::numeric_limits<int8_t>::max());
check(STR("127"), STR("{:#}"), std::numeric_limits<int8_t>::max());
check(STR("0x7f"), STR("{:#x}"), std::numeric_limits<int8_t>::max());
- check(STR("0b111111111111111"), STR("{:#b}"),
- std::numeric_limits<int16_t>::max());
+ check(STR("0b111111111111111"), STR("{:#b}"), std::numeric_limits<int16_t>::max());
check(STR("077777"), STR("{:#o}"), std::numeric_limits<int16_t>::max());
check(STR("32767"), STR("{:#}"), std::numeric_limits<int16_t>::max());
check(STR("0x7fff"), STR("{:#x}"), std::numeric_limits<int16_t>::max());
- check(STR("0b1111111111111111111111111111111"), STR("{:#b}"),
- std::numeric_limits<int32_t>::max());
+ check(STR("0b1111111111111111111111111111111"), STR("{:#b}"), std::numeric_limits<int32_t>::max());
check(STR("017777777777"), STR("{:#o}"), std::numeric_limits<int32_t>::max());
check(STR("2147483647"), STR("{:#}"), std::numeric_limits<int32_t>::max());
check(STR("0x7fffffff"), STR("{:#x}"), std::numeric_limits<int32_t>::max());
- check(
- STR("0b111111111111111111111111111111111111111111111111111111111111111"),
- STR("{:#b}"), std::numeric_limits<int64_t>::max());
- check(STR("0777777777777777777777"), STR("{:#o}"),
- std::numeric_limits<int64_t>::max());
- check(STR("9223372036854775807"), STR("{:#}"),
- std::numeric_limits<int64_t>::max());
- check(STR("0x7fffffffffffffff"), STR("{:#x}"),
+ check(STR("0b111111111111111111111111111111111111111111111111111111111111111"), STR("{:#b}"),
std::numeric_limits<int64_t>::max());
+ check(STR("0777777777777777777777"), STR("{:#o}"), std::numeric_limits<int64_t>::max());
+ check(STR("9223372036854775807"), STR("{:#}"), std::numeric_limits<int64_t>::max());
+ check(STR("0x7fffffffffffffff"), STR("{:#x}"), std::numeric_limits<int64_t>::max());
// TODO FMT Add __int128_t test after implementing full range.
}
template <class CharT, class TestFunction, class ExceptionTest>
-void format_test_unsigned_integer(TestFunction check,
- ExceptionTest check_exception) {
+void format_test_unsigned_integer(TestFunction check, ExceptionTest check_exception) {
format_test_integer<unsigned char, CharT>(check, check_exception);
format_test_integer<unsigned short, CharT>(check, check_exception);
format_test_integer<unsigned, CharT>(check, check_exception);
@@ -909,28 +799,21 @@ void format_test_unsigned_integer(TestFunction check,
check(STR("255"), STR("{:#}"), std::numeric_limits<uint8_t>::max());
check(STR("0xff"), STR("{:#x}"), std::numeric_limits<uint8_t>::max());
- check(STR("0b1111111111111111"), STR("{:#b}"),
- std::numeric_limits<uint16_t>::max());
+ check(STR("0b1111111111111111"), STR("{:#b}"), std::numeric_limits<uint16_t>::max());
check(STR("0177777"), STR("{:#o}"), std::numeric_limits<uint16_t>::max());
check(STR("65535"), STR("{:#}"), std::numeric_limits<uint16_t>::max());
check(STR("0xffff"), STR("{:#x}"), std::numeric_limits<uint16_t>::max());
- check(STR("0b11111111111111111111111111111111"), STR("{:#b}"),
- std::numeric_limits<uint32_t>::max());
- check(STR("037777777777"), STR("{:#o}"),
- std::numeric_limits<uint32_t>::max());
+ check(STR("0b11111111111111111111111111111111"), STR("{:#b}"), std::numeric_limits<uint32_t>::max());
+ check(STR("037777777777"), STR("{:#o}"), std::numeric_limits<uint32_t>::max());
check(STR("4294967295"), STR("{:#}"), std::numeric_limits<uint32_t>::max());
check(STR("0xffffffff"), STR("{:#x}"), std::numeric_limits<uint32_t>::max());
- check(
- STR("0b1111111111111111111111111111111111111111111111111111111111111111"),
- STR("{:#b}"), std::numeric_limits<uint64_t>::max());
- check(STR("01777777777777777777777"), STR("{:#o}"),
- std::numeric_limits<uint64_t>::max());
- check(STR("18446744073709551615"), STR("{:#}"),
- std::numeric_limits<uint64_t>::max());
- check(STR("0xffffffffffffffff"), STR("{:#x}"),
+ check(STR("0b1111111111111111111111111111111111111111111111111111111111111111"), STR("{:#b}"),
std::numeric_limits<uint64_t>::max());
+ check(STR("01777777777777777777777"), STR("{:#o}"), std::numeric_limits<uint64_t>::max());
+ check(STR("18446744073709551615"), STR("{:#}"), std::numeric_limits<uint64_t>::max());
+ check(STR("0xffffffffffffffff"), STR("{:#x}"), std::numeric_limits<uint64_t>::max());
// TODO FMT Add __uint128_t test after implementing full range.
}
@@ -959,46 +842,30 @@ void format_test_char(TestFunction check, ExceptionTest check_exception) {
check(STR("answer is '--*---'"), STR("answer is '{:-^6c}'"), CharT('*'));
// *** Sign ***
- check_exception("A sign field isn't allowed in this format-spec", STR("{:-}"),
- CharT('*'));
- check_exception("A sign field isn't allowed in this format-spec", STR("{:+}"),
- CharT('*'));
- check_exception("A sign field isn't allowed in this format-spec", STR("{: }"),
- CharT('*'));
-
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{:-c}"), CharT('*'));
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{:+c}"), CharT('*'));
- check_exception("A sign field isn't allowed in this format-spec",
- STR("{: c}"), CharT('*'));
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:-}"), CharT('*'));
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:+}"), CharT('*'));
+ check_exception("A sign field isn't allowed in this format-spec", STR("{: }"), CharT('*'));
+
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:-c}"), CharT('*'));
+ check_exception("A sign field isn't allowed in this format-spec", STR("{:+c}"), CharT('*'));
+ check_exception("A sign field isn't allowed in this format-spec", STR("{: c}"), CharT('*'));
// *** alternate form ***
- check_exception("An alternate form field isn't allowed in this format-spec",
- STR("{:#}"), CharT('*'));
- check_exception("An alternate form field isn't allowed in this format-spec",
- STR("{:#c}"), CharT('*'));
+ check_exception("An alternate form field isn't allowed in this format-spec", STR("{:#}"), CharT('*'));
+ check_exception("An alternate form field isn't allowed in this format-spec", STR("{:#c}"), CharT('*'));
// *** zero-padding ***
- check_exception("A zero-padding field isn't allowed in this format-spec",
- STR("{:0}"), CharT('*'));
- check_exception("A zero-padding field isn't allowed in this format-spec",
- STR("{:0c}"), CharT('*'));
+ check_exception("A zero-padding field isn't allowed in this format-spec", STR("{:0}"), CharT('*'));
+ check_exception("A zero-padding field isn't allowed in this format-spec", STR("{:0c}"), CharT('*'));
// *** precision ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.}"), CharT('*'));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0}"), CharT('*'));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42}"), CharT('*'));
-
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.c}"), CharT('*'));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0c}"), CharT('*'));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42c}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42}"), CharT('*'));
+
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.c}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0c}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42c}"), CharT('*'));
// *** locale-specific form ***
// Note it has no effect but it's allowed.
@@ -1007,14 +874,11 @@ void format_test_char(TestFunction check, ExceptionTest check_exception) {
// *** type ***
for (const auto& fmt : invalid_types<CharT>("bBcdoxX"))
- check_exception(
- "The format-spec type has a type not supported for a char argument",
- fmt, CharT('*'));
+ check_exception("The format-spec type has a type not supported for a char argument", fmt, CharT('*'));
}
template <class CharT, class TestFunction, class ExceptionTest>
-void format_test_char_as_integer(TestFunction check,
- ExceptionTest check_exception) {
+void format_test_char_as_integer(TestFunction check, ExceptionTest check_exception) {
// *** align-fill & width ***
check(STR("answer is '42'"), STR("answer is '{:<1d}'"), CharT('*'));
@@ -1067,21 +931,16 @@ void format_test_char_as_integer(TestFunction check,
check(STR("answer is +0X00000002A"), STR("answer is {:+#012X}"), CharT('*'));
// *** precision ***
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.d}"), CharT('*'));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.0d}"), CharT('*'));
- check_exception("The format-spec should consume the input or end with a '}'",
- STR("{:.42d}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.d}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.0d}"), CharT('*'));
+ check_exception("The format-spec should consume the input or end with a '}'", STR("{:.42d}"), CharT('*'));
// *** locale-specific form ***
// See locale-specific_form.pass.cpp
// *** type ***
for (const auto& fmt : invalid_types<CharT>("bBcdoxX"))
- check_exception(
- "The format-spec type has a type not supported for a char argument",
- fmt, '*');
+ check_exception("The format-spec type has a type not supported for a char argument", fmt, '*');
}
template <class F, class CharT, class TestFunction>
@@ -2650,42 +2509,34 @@ void format_tests(TestFunction check, ExceptionTest check_exception) {
// ** Test invalid format strings ***
check_exception("The format string terminates at a '{'", STR("{"));
- check_exception("The replacement field misses a terminating '}'", STR("{:"),
- 42);
+ check_exception("The replacement field misses a terminating '}'", STR("{:"), 42);
- check_exception("The format string contains an invalid escape sequence",
- STR("}"));
- check_exception("The format string contains an invalid escape sequence",
- STR("{:}-}"), 42);
+ check_exception("The format string contains an invalid escape sequence", STR("}"));
+ check_exception("The format string contains an invalid escape sequence", STR("{:}-}"), 42);
- check_exception("The format string contains an invalid escape sequence",
- STR("} "));
+ check_exception("The format string contains an invalid escape sequence", STR("} "));
- check_exception(
- "The arg-id of the format-spec starts with an invalid character",
- STR("{-"), 42);
+ check_exception("The arg-id of the format-spec starts with an invalid character", STR("{-"), 42);
check_exception("Argument index out of bounds", STR("hello {}"));
check_exception("Argument index out of bounds", STR("hello {0}"));
check_exception("Argument index out of bounds", STR("hello {1}"), 42);
// *** Test char format argument ***
// The `char` to `wchar_t` formatting is tested separately.
- check(STR("hello 09azAZ!"), STR("hello {}{}{}{}{}{}{}"), CharT('0'),
- CharT('9'), CharT('a'), CharT('z'), CharT('A'), CharT('Z'), CharT('!'));
+ check(STR("hello 09azAZ!"), STR("hello {}{}{}{}{}{}{}"), CharT('0'), CharT('9'), CharT('a'), CharT('z'), CharT('A'),
+ CharT('Z'), CharT('!'));
format_test_char<CharT>(check, check_exception);
format_test_char_as_integer<CharT>(check, check_exception);
// *** Test string format argument ***
{
- CharT buffer[] = {CharT('0'), CharT('9'), CharT('a'), CharT('z'),
- CharT('A'), CharT('Z'), CharT('!'), 0};
+ CharT buffer[] = {CharT('0'), CharT('9'), CharT('a'), CharT('z'), CharT('A'), CharT('Z'), CharT('!'), 0};
CharT* data = buffer;
check(STR("hello 09azAZ!"), STR("hello {}"), data);
}
{
- CharT buffer[] = {CharT('0'), CharT('9'), CharT('a'), CharT('z'),
- CharT('A'), CharT('Z'), CharT('!'), 0};
+ CharT buffer[] = {CharT('0'), CharT('9'), CharT('a'), CharT('z'), CharT('A'), CharT('Z'), CharT('!'), 0};
const CharT* data = buffer;
check(STR("hello 09azAZ!"), STR("hello {}"), data);
}
@@ -2718,20 +2569,14 @@ void format_tests(TestFunction check, ExceptionTest check_exception) {
{
// Note 128-bit support is only partly implemented test the range
// conditions here.
- std::basic_string<CharT> min =
- std::format(STR("{}"), std::numeric_limits<long long>::min());
- check(min, STR("{}"),
- static_cast<__int128_t>(std::numeric_limits<long long>::min()));
- std::basic_string<CharT> max =
- std::format(STR("{}"), std::numeric_limits<long long>::max());
- check(max, STR("{}"),
- static_cast<__int128_t>(std::numeric_limits<long long>::max()));
- check_exception(
- "128-bit value is outside of implemented range", STR("{}"),
- static_cast<__int128_t>(std::numeric_limits<long long>::min()) - 1);
- check_exception(
- "128-bit value is outside of implemented range", STR("{}"),
- static_cast<__int128_t>(std::numeric_limits<long long>::max()) + 1);
+ std::basic_string<CharT> min = std::format(STR("{}"), std::numeric_limits<long long>::min());
+ check(min, STR("{}"), static_cast<__int128_t>(std::numeric_limits<long long>::min()));
+ std::basic_string<CharT> max = std::format(STR("{}"), std::numeric_limits<long long>::max());
+ check(max, STR("{}"), static_cast<__int128_t>(std::numeric_limits<long long>::max()));
+ check_exception("128-bit value is outside of implemented range", STR("{}"),
+ static_cast<__int128_t>(std::numeric_limits<long long>::min()) - 1);
+ check_exception("128-bit value is outside of implemented range", STR("{}"),
+ static_cast<__int128_t>(std::numeric_limits<long long>::max()) + 1);
}
#endif
format_test_signed_integer<CharT>(check, check_exception);
@@ -2747,15 +2592,10 @@ void format_tests(TestFunction check, ExceptionTest check_exception) {
{
// Note 128-bit support is only partly implemented test the range
// conditions here.
- std::basic_string<CharT> max =
- std::format(STR("{}"), std::numeric_limits<unsigned long long>::max());
- check(max, STR("{}"),
- static_cast<__uint128_t>(
- std::numeric_limits<unsigned long long>::max()));
+ std::basic_string<CharT> max = std::format(STR("{}"), std::numeric_limits<unsigned long long>::max());
+ check(max, STR("{}"), static_cast<__uint128_t>(std::numeric_limits<unsigned long long>::max()));
check_exception("128-bit value is outside of implemented range", STR("{}"),
- static_cast<__uint128_t>(
- std::numeric_limits<unsigned long long>::max()) +
- 1);
+ static_cast<__uint128_t>(std::numeric_limits<unsigned long long>::max()) + 1);
}
#endif
format_test_unsigned_integer<CharT>(check, check_exception);
diff --git a/libcxx/test/std/utilities/format/format.functions/format_to.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format_to.locale.pass.cpp
index 98356fdd8bd66..b403105cb121d 100644
--- a/libcxx/test/std/utilities/format/format.functions/format_to.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format_to.locale.pass.cpp
@@ -30,8 +30,7 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
{
std::basic_string<CharT> out(expected.size(), CharT(' '));
@@ -42,14 +41,12 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
{
std::list<CharT> out;
std::format_to(std::back_inserter(out), std::locale(), fmt, args...);
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
std::vector<CharT> out;
std::format_to(std::back_inserter(out), std::locale(), fmt, args...);
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
assert(expected.size() < 4096 && "Update the size of the buffer.");
@@ -61,8 +58,8 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
}
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::basic_string<CharT> out;
diff --git a/libcxx/test/std/utilities/format/format.functions/format_to.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format_to.pass.cpp
index d8d24f92d60cc..cf46a0092eb16 100644
--- a/libcxx/test/std/utilities/format/format.functions/format_to.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format_to.pass.cpp
@@ -31,8 +31,7 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
{
std::basic_string<CharT> out(expected.size(), CharT(' '));
@@ -43,14 +42,12 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
{
std::list<CharT> out;
std::format_to(std::back_inserter(out), fmt, args...);
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
std::vector<CharT> out;
std::format_to(std::back_inserter(out), fmt, args...);
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
assert(expected.size() < 4096 && "Update the size of the buffer.");
@@ -62,8 +59,8 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
}
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::basic_string<CharT> out;
diff --git a/libcxx/test/std/utilities/format/format.functions/format_to_n.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format_to_n.locale.pass.cpp
index 206450b53c466..1dc1745a1fd3f 100644
--- a/libcxx/test/std/utilities/format/format.functions/format_to_n.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format_to_n.locale.pass.cpp
@@ -32,13 +32,11 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
{
std::list<CharT> out;
- std::format_to_n_result result = std::format_to_n(
- std::back_inserter(out), 0, std::locale(), fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 0, std::locale(), fmt, args...);
// To avoid signedness warnings make sure formatted_size uses the same type
// as result.size.
using
diff _type = decltype(result.size);
@@ -49,20 +47,17 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
}
{
std::vector<CharT> out;
- std::format_to_n_result result = std::format_to_n(
- std::back_inserter(out), 5, std::locale(), fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 5, std::locale(), fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(std::locale(), fmt, args...);
diff _type size = std::min<
diff _type>(5, formatted_size);
assert(result.size == formatted_size);
- assert(std::equal(out.begin(), out.end(), expected.begin(),
- expected.begin() + size));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.begin() + size));
}
{
std::basic_string<CharT> out;
- std::format_to_n_result result = std::format_to_n(
- std::back_inserter(out), 1000, std::locale(), fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 1000, std::locale(), fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(std::locale(), fmt, args...);
diff _type size = std::min<
diff _type>(1000, formatted_size);
@@ -73,8 +68,7 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
{
// Test the returned iterator.
std::basic_string<CharT> out(10, CharT(' '));
- std::format_to_n_result result =
- std::format_to_n(out.begin(), 10, std::locale(), fmt, args...);
+ std::format_to_n_result result = std::format_to_n(out.begin(), 10, std::locale(), fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(std::locale(), fmt, args...);
diff _type size = std::min<
diff _type>(10, formatted_size);
@@ -88,8 +82,7 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
"If the
diff erence type isn't negative the test will fail "
"due to using a large positive value.");
CharT buffer[1] = {CharT(0)};
- std::format_to_n_result result =
- std::format_to_n(buffer, -1, std::locale(), fmt, args...);
+ std::format_to_n_result result = std::format_to_n(buffer, -1, std::locale(), fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(std::locale(), fmt, args...);
@@ -99,8 +92,8 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
}
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::basic_string<CharT> out;
diff --git a/libcxx/test/std/utilities/format/format.functions/format_to_n.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format_to_n.pass.cpp
index 6f69af4d99df9..a964fc2f6edf7 100644
--- a/libcxx/test/std/utilities/format/format.functions/format_to_n.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format_to_n.pass.cpp
@@ -29,13 +29,11 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
{
std::list<CharT> out;
- std::format_to_n_result result =
- std::format_to_n(std::back_inserter(out), 0, fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 0, fmt, args...);
// To avoid signedness warnings make sure formatted_size uses the same type
// as result.size.
using
diff _type = decltype(result.size);
@@ -46,20 +44,17 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
}
{
std::vector<CharT> out;
- std::format_to_n_result result =
- std::format_to_n(std::back_inserter(out), 5, fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 5, fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(fmt, args...);
diff _type size = std::min<
diff _type>(5, formatted_size);
assert(result.size == formatted_size);
- assert(std::equal(out.begin(), out.end(), expected.begin(),
- expected.begin() + size));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.begin() + size));
}
{
std::basic_string<CharT> out;
- std::format_to_n_result result =
- std::format_to_n(std::back_inserter(out), 1000, fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 1000, fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(fmt, args...);
diff _type size = std::min<
diff _type>(1000, formatted_size);
@@ -70,8 +65,7 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
{
// Test the returned iterator.
std::basic_string<CharT> out(10, CharT(' '));
- std::format_to_n_result result =
- std::format_to_n(out.begin(), 10, fmt, args...);
+ std::format_to_n_result result = std::format_to_n(out.begin(), 10, fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(fmt, args...);
diff _type size = std::min<
diff _type>(10, formatted_size);
@@ -95,8 +89,8 @@ auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
}
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::basic_string<CharT> out;
diff --git a/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.pass.cpp
index b31170b62c596..34f13191f17f4 100644
--- a/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.pass.cpp
@@ -28,15 +28,14 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
size_t size = std::formatted_size(std::locale(), fmt, args...);
assert(size == expected.size());
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::formatted_size(std::locale(), fmt, args...);
diff --git a/libcxx/test/std/utilities/format/format.functions/formatted_size.pass.cpp b/libcxx/test/std/utilities/format/format.functions/formatted_size.pass.cpp
index befb4ce626109..4171573d1348f 100644
--- a/libcxx/test/std/utilities/format/format.functions/formatted_size.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/formatted_size.pass.cpp
@@ -25,15 +25,14 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
size_t size = std::formatted_size(fmt, args...);
assert(size == expected.size());
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::formatted_size(fmt, args...);
diff --git a/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp b/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
index 5d86e46be7e6b..6f21454975117 100644
--- a/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
@@ -126,21 +126,19 @@ struct numpunct<wchar_t> : std::numpunct<wchar_t> {
#endif
template <class CharT, class... Args>
-void test(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
- const Args&... args) {
+void test(std::basic_string<CharT> expected, std::basic_string<CharT> fmt, const Args&... args) {
// *** format ***
{
std::basic_string<CharT> out = std::format(fmt, args...);
if constexpr (std::same_as<CharT, char>)
if (out != expected)
- std::cerr << "\nFormat string " << fmt << "\nExpected output "
- << expected << "\nActual output " << out << '\n';
+ std::cerr << "\nFormat string " << fmt << "\nExpected output " << expected << "\nActual output " << out
+ << '\n';
assert(out == expected);
}
// *** vformat ***
{
- std::basic_string<CharT> out =
- std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
+ std::basic_string<CharT> out = std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
assert(out == expected);
}
// *** format_to ***
@@ -153,16 +151,14 @@ void test(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
// *** vformat_to ***
{
std::basic_string<CharT> out(expected.size(), CharT(' '));
- auto it = std::vformat_to(out.begin(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ auto it = std::vformat_to(out.begin(), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(it == out.end());
assert(out == expected);
}
// *** format_to_n ***
{
std::basic_string<CharT> out;
- std::format_to_n_result result =
- std::format_to_n(std::back_inserter(out), 1000, fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 1000, fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(fmt, args...);
diff _type size = std::min<
diff _type>(1000, formatted_size);
@@ -178,21 +174,19 @@ void test(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
}
template <class CharT, class... Args>
-void test(std::basic_string<CharT> expected, std::locale loc,
- std::basic_string<CharT> fmt, const Args&... args) {
+void test(std::basic_string<CharT> expected, std::locale loc, std::basic_string<CharT> fmt, const Args&... args) {
// *** format ***
{
std::basic_string<CharT> out = std::format(loc, fmt, args...);
if constexpr (std::same_as<CharT, char>)
if (out != expected)
- std::cerr << "\nFormat string " << fmt << "\nExpected output "
- << expected << "\nActual output " << out << '\n';
+ std::cerr << "\nFormat string " << fmt << "\nExpected output " << expected << "\nActual output " << out
+ << '\n';
assert(out == expected);
}
// *** vformat ***
{
- std::basic_string<CharT> out = std::vformat(
- loc, fmt, std::make_format_args<context_t<CharT>>(args...));
+ std::basic_string<CharT> out = std::vformat(loc, fmt, std::make_format_args<context_t<CharT>>(args...));
assert(out == expected);
}
// *** format_to ***
@@ -205,16 +199,14 @@ void test(std::basic_string<CharT> expected, std::locale loc,
// *** vformat_to ***
{
std::basic_string<CharT> out(expected.size(), CharT(' '));
- auto it = std::vformat_to(out.begin(), loc, fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ auto it = std::vformat_to(out.begin(), loc, fmt, std::make_format_args<context_t<CharT>>(args...));
assert(it == out.end());
assert(out == expected);
}
// *** format_to_n ***
{
std::basic_string<CharT> out;
- std::format_to_n_result result =
- std::format_to_n(std::back_inserter(out), 1000, loc, fmt, args...);
+ std::format_to_n_result result = std::format_to_n(std::back_inserter(out), 1000, loc, fmt, args...);
using
diff _type = decltype(result.size);
diff _type formatted_size = std::formatted_size(loc, fmt, args...);
diff _type size = std::min<
diff _type>(1000, formatted_size);
@@ -239,13 +231,13 @@ struct numpunct_unicode<char> : std::numpunct<char> {
string_type do_falsename() const override { return "ungültig"; }
};
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+# ifndef TEST_HAS_NO_WIDE_CHARACTERS
template <>
struct numpunct_unicode<wchar_t> : std::numpunct<wchar_t> {
string_type do_truename() const override { return L"gültig"; }
string_type do_falsename() const override { return L"ungültig"; }
};
-#endif
+# endif
#endif // TEST_HAS_NO_UNICODE
template <class CharT>
@@ -268,8 +260,7 @@ void test_bool() {
test(STR("false"), std::locale(LOCALE_en_US_UTF_8), STR("{:L}"), false);
#ifndef TEST_HAS_NO_UNICODE
- std::locale loc_unicode =
- std::locale(std::locale(), new numpunct_unicode<CharT>());
+ std::locale loc_unicode = std::locale(std::locale(), new numpunct_unicode<CharT>());
test(STR("gültig"), loc_unicode, STR("{:L}"), true);
test(STR("ungültig"), loc_unicode, STR("{:L}"), false);
diff --git a/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
index c9dbab1002c4e..3bad47da7af95 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
@@ -24,20 +24,17 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
- std::basic_string<CharT> out = std::vformat(
- std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
+ std::basic_string<CharT> out = std::vformat(std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(out == expected);
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
- (void) std::vformat(std::locale(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ (void)std::vformat(std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(false);
} catch ([[maybe_unused]] std::format_error& e) {
LIBCPP_ASSERT(e.what() == what);
diff --git a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
index 8688d560c41c6..effcd722ba9d4 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
@@ -23,16 +23,14 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
- std::basic_string<CharT> out =
- std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
+ std::basic_string<CharT> out = std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
assert(out == expected);
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
TEST_IGNORE_NODISCARD std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
diff --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
index 737f618085591..b441656cfc599 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
@@ -30,49 +30,40 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
{
std::basic_string<CharT> out(expected.size(), CharT(' '));
- auto it = std::vformat_to(out.begin(), std::locale(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ auto it = std::vformat_to(out.begin(), std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(it == out.end());
assert(out == expected);
}
{
std::list<CharT> out;
- std::vformat_to(std::back_inserter(out), std::locale(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ std::vformat_to(std::back_inserter(out), std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
std::vector<CharT> out;
- std::vformat_to(std::back_inserter(out), std::locale(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ std::vformat_to(std::back_inserter(out), std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
assert(expected.size() < 4096 && "Update the size of the buffer.");
CharT out[4096];
- CharT* it =
- std::vformat_to(out, std::locale(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ CharT* it = std::vformat_to(out, std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(std::distance(out, it) == int(expected.size()));
// Convert to std::string since output contains '\0' for boolean tests.
assert(std::basic_string<CharT>(out, it) == expected);
}
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::basic_string<CharT> out;
- std::vformat_to(std::back_inserter(out), std::locale(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ std::vformat_to(std::back_inserter(out), std::locale(), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(false);
} catch ([[maybe_unused]] std::format_error& e) {
LIBCPP_ASSERT(e.what() == what);
diff --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
index 0bec98a13b7a2..e6880d780f513 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
@@ -31,48 +31,40 @@
#include "test_macros.h"
#include "format_tests.h"
-auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected,
- std::basic_string<CharT> fmt,
+auto test = []<class CharT, class... Args>(std::basic_string<CharT> expected, std::basic_string<CharT> fmt,
const Args&... args) {
{
std::basic_string<CharT> out(expected.size(), CharT(' '));
- auto it = std::vformat_to(out.begin(), fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ auto it = std::vformat_to(out.begin(), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(it == out.end());
assert(out == expected);
}
{
std::list<CharT> out;
- std::vformat_to(std::back_inserter(out), fmt,
- std::make_format_args<context_t<CharT>>(args...));
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ std::vformat_to(std::back_inserter(out), fmt, std::make_format_args<context_t<CharT>>(args...));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
std::vector<CharT> out;
- std::vformat_to(std::back_inserter(out), fmt,
- std::make_format_args<context_t<CharT>>(args...));
- assert(
- std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
+ std::vformat_to(std::back_inserter(out), fmt, std::make_format_args<context_t<CharT>>(args...));
+ assert(std::equal(out.begin(), out.end(), expected.begin(), expected.end()));
}
{
assert(expected.size() < 4096 && "Update the size of the buffer.");
CharT out[4096];
- CharT* it = std::vformat_to(
- out, fmt, std::make_format_args<context_t<CharT>>(args...));
+ CharT* it = std::vformat_to(out, fmt, std::make_format_args<context_t<CharT>>(args...));
assert(std::distance(out, it) == int(expected.size()));
// Convert to std::string since output contains '\0' for boolean tests.
assert(std::basic_string<CharT>(out, it) == expected);
}
};
-auto test_exception = []<class CharT, class... Args>(
- std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
+auto test_exception =
+ []<class CharT, class... Args>(std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
std::basic_string<CharT> out;
- std::vformat_to(std::back_inserter(out), fmt,
- std::make_format_args<context_t<CharT>>(args...));
+ std::vformat_to(std::back_inserter(out), fmt, std::make_format_args<context_t<CharT>>(args...));
assert(false);
} catch ([[maybe_unused]] std::format_error& e) {
LIBCPP_ASSERT(e.what() == what);
More information about the libcxx-commits
mailing list