diff --git a/include/fmt/os.h b/include/fmt/os.h index b5afd463..b64f8bbf 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -28,8 +28,9 @@ # endif # if (FMT_HAS_INCLUDE() || defined(__APPLE__) || \ defined(__linux__)) && \ - (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) -# include // for O_RDONLY + (!defined(WINAPI_FAMILY) || \ + (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) +# include // for O_RDONLY # define FMT_USE_FCNTL 1 # else # define FMT_USE_FCNTL 0 @@ -395,10 +396,10 @@ struct ostream_params { // Intel has a bug that results in failure to deduce a constructor // for empty parameter packs. -#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 2000 +# if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 2000 ostream_params(int new_oflag) : oflag(new_oflag) {} ostream_params(detail::buffer_size bs) : buffer_size(bs.value) {} -#endif +# endif }; FMT_END_DETAIL_NAMESPACE diff --git a/src/fmt.cc b/src/fmt.cc index d0d6e7fb..80e77e26 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -79,7 +79,6 @@ export module fmt; #define FMT_END_DETAIL_NAMESPACE \ } \ export { - // all library-provided declarations and definitions // must be in the module purview to be exported #include "fmt/args.h" diff --git a/test/chrono-test.cc b/test/chrono-test.cc index 1fbe2a73..a2bc20c2 100644 --- a/test/chrono-test.cc +++ b/test/chrono-test.cc @@ -453,9 +453,9 @@ TEST(chrono_test, format_default_fp) { } TEST(chrono_test, format_precision) { - EXPECT_THROW_MSG((void)fmt::format(runtime("{:.2}"), std::chrono::seconds(42)), - fmt::format_error, - "precision not allowed for this argument type"); + EXPECT_THROW_MSG( + (void)fmt::format(runtime("{:.2}"), std::chrono::seconds(42)), + fmt::format_error, "precision not allowed for this argument type"); EXPECT_EQ("1ms", fmt::format("{:.0}", dms(1.234))); EXPECT_EQ("1.2ms", fmt::format("{:.1}", dms(1.234))); EXPECT_EQ("1.23ms", fmt::format("{:.{}}", dms(1.234), 2)); @@ -493,9 +493,9 @@ TEST(chrono_test, format_simple_q) { } TEST(chrono_test, format_precision_q) { - EXPECT_THROW_MSG((void)fmt::format(runtime("{:.2%Q %q}"), std::chrono::seconds(42)), - fmt::format_error, - "precision not allowed for this argument type"); + EXPECT_THROW_MSG( + (void)fmt::format(runtime("{:.2%Q %q}"), std::chrono::seconds(42)), + fmt::format_error, "precision not allowed for this argument type"); EXPECT_EQ("1.2 ms", fmt::format("{:.1%Q %q}", dms(1.234))); EXPECT_EQ("1.23 ms", fmt::format("{:.{}%Q %q}", dms(1.234), 2)); } @@ -551,7 +551,7 @@ TEST(chrono_test, special_durations) { "nan nan nan nan nan:nan nan", fmt::format("{:%I %H %M %S %R %r}", std::chrono::duration(nan))); (void)fmt::format("{:%S}", - std::chrono::duration(1.79400457e+31f)); + std::chrono::duration(1.79400457e+31f)); EXPECT_EQ(fmt::format("{}", std::chrono::duration(1)), "1Es"); EXPECT_EQ(fmt::format("{}", std::chrono::duration(1)), diff --git a/test/enforce-checks-test.cc b/test/enforce-checks-test.cc index c6be10ab..c77cb142 100644 --- a/test/enforce-checks-test.cc +++ b/test/enforce-checks-test.cc @@ -41,7 +41,8 @@ void test_chrono() { void test_text_style() { fmt::print(fg(fmt::rgb(255, 20, 30)), FMT_STRING("{}"), "rgb(255,20,30)"); - (void)fmt::format(fg(fmt::rgb(255, 20, 30)), FMT_STRING("{}"), "rgb(255,20,30)"); + (void)fmt::format(fg(fmt::rgb(255, 20, 30)), FMT_STRING("{}"), + "rgb(255,20,30)"); fmt::text_style ts = fg(fmt::rgb(255, 20, 30)); std::string out; diff --git a/test/find-package-test/main.cc b/test/find-package-test/main.cc index f39f377c..911e0e8d 100644 --- a/test/find-package-test/main.cc +++ b/test/find-package-test/main.cc @@ -1,6 +1,5 @@ #include "fmt/format.h" int main(int argc, char** argv) { - for(int i = 0; i < argc; ++i) - fmt::print("{}: {}\n", i, argv[i]); + for (int i = 0; i < argc; ++i) fmt::print("{}: {}\n", i, argv[i]); } diff --git a/test/format-test.cc b/test/format-test.cc index 2fb2037c..37101387 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -471,9 +471,11 @@ TEST(format_test, auto_arg_index) { EXPECT_THROW_MSG((void)fmt::format(runtime("{}{0}"), 'a', 'b'), format_error, "cannot switch from automatic to manual argument indexing"); EXPECT_EQ("1.2", fmt::format("{:.{}}", 1.2345, 2)); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0}:.{}"), 1.2345, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0}:.{}"), 1.2345, 2), + format_error, "cannot switch from manual to automatic argument indexing"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{:.{0}}"), 1.2345, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{:.{0}}"), 1.2345, 2), + format_error, "cannot switch from automatic to manual argument indexing"); EXPECT_THROW_MSG((void)fmt::format(runtime("{}")), format_error, "argument not found"); @@ -578,8 +580,9 @@ TEST(format_test, plus_sign) { "invalid format specifier for char"); EXPECT_THROW_MSG((void)fmt::format(runtime("{0:+}"), "abc"), format_error, "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:+}"), reinterpret_cast(0x42)), - format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG( + (void)fmt::format(runtime("{0:+}"), reinterpret_cast(0x42)), + format_error, "format specifier requires numeric argument"); } TEST(format_test, minus_sign) { @@ -602,8 +605,9 @@ TEST(format_test, minus_sign) { "invalid format specifier for char"); EXPECT_THROW_MSG((void)fmt::format(runtime("{0:-}"), "abc"), format_error, "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:-}"), reinterpret_cast(0x42)), - format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG( + (void)fmt::format(runtime("{0:-}"), reinterpret_cast(0x42)), + format_error, "format specifier requires numeric argument"); } TEST(format_test, space_sign) { @@ -626,8 +630,9 @@ TEST(format_test, space_sign) { "invalid format specifier for char"); EXPECT_THROW_MSG((void)fmt::format(runtime("{0: }"), "abc"), format_error, "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0: }"), reinterpret_cast(0x42)), - format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG( + (void)fmt::format(runtime("{0: }"), reinterpret_cast(0x42)), + format_error, "format specifier requires numeric argument"); } TEST(format_test, hash_flag) { @@ -676,8 +681,9 @@ TEST(format_test, hash_flag) { "invalid format specifier for char"); EXPECT_THROW_MSG((void)fmt::format(runtime("{0:#}"), "abc"), format_error, "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:#}"), reinterpret_cast(0x42)), - format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG( + (void)fmt::format(runtime("{0:#}"), reinterpret_cast(0x42)), + format_error, "format specifier requires numeric argument"); } TEST(format_test, zero_flag) { @@ -908,9 +914,9 @@ TEST(format_test, precision) { EXPECT_THROW_MSG( (void)fmt::format(runtime("{0:.2f}"), reinterpret_cast(0xcafe)), format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG( - (void)fmt::format(runtime("{:.{}e}"), 42.0, fmt::detail::max_value()), - format_error, "number is too big"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{:.{}e}"), 42.0, + fmt::detail::max_value()), + format_error, "number is too big"); EXPECT_EQ("st", fmt::format("{0:.2}", "str")); } @@ -970,35 +976,46 @@ TEST(format_test, runtime_precision) { "precision not allowed for this argument type"); EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42u, 2), format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42u, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42u, 2), + format_error, "precision not allowed for this argument type"); EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42l, 2), format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42l, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42l, 2), + format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42ul, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42ul, 2), + format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42ul, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42ul, 2), + format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42ll, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42ll, 2), + format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42ll, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42ll, 2), + format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42ull, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), 42ull, 2), + format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42ull, 2), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), 42ull, 2), + format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:3.{1}}"), 'x', 0), format_error, + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:3.{1}}"), 'x', 0), + format_error, "precision not allowed for this argument type"); EXPECT_EQ("1.2", fmt::format("{0:.{1}}", 1.2345, 2)); EXPECT_EQ("1.2", fmt::format("{1:.{0}}", 2, 1.2345l)); - EXPECT_THROW_MSG( - (void)fmt::format(runtime("{0:.{1}}"), reinterpret_cast(0xcafe), 2), - format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG( - (void)fmt::format(runtime("{0:.{1}f}"), reinterpret_cast(0xcafe), 2), - format_error, "precision not allowed for this argument type"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}}"), + reinterpret_cast(0xcafe), 2), + format_error, + "precision not allowed for this argument type"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:.{1}f}"), + reinterpret_cast(0xcafe), 2), + format_error, + "precision not allowed for this argument type"); EXPECT_EQ("st", fmt::format("{0:.{1}}", "str", 2)); } @@ -1029,8 +1046,8 @@ void check_unknown_types(const T& value, const char* types, const char*) { if (std::strchr(types, c) || std::strchr(special, c) || !c) continue; safe_sprintf(format_str, "{0:10%c}", c); const char* message = "invalid type specifier"; - EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), value), format_error, - message) + EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), value), + format_error, message) << format_str << " " << message; } } @@ -1558,8 +1575,9 @@ TEST(format_test, format_examples) { fmt::format("int: {0:d}; hex: {0:#x}; oct: {0:#o}", 42)); EXPECT_EQ("The answer is 42", fmt::format("The answer is {}", 42)); - EXPECT_THROW_MSG((void)fmt::format(runtime("The answer is {:d}"), "forty-two"), - format_error, "invalid type specifier"); + EXPECT_THROW_MSG( + (void)fmt::format(runtime("The answer is {:d}"), "forty-two"), + format_error, "invalid type specifier"); EXPECT_WRITE( stdout, fmt::print("{}", std::numeric_limits::infinity()), "inf"); diff --git a/test/gtest-extra.h b/test/gtest-extra.h index 3a3a96cf..df2b1d8c 100644 --- a/test/gtest-extra.h +++ b/test/gtest-extra.h @@ -15,8 +15,8 @@ #ifdef FMT_MODULE_TEST import fmt; #else -#include "fmt/os.h" -#endif // FMG_MODULE_TEST +# include "fmt/os.h" +#endif // FMG_MODULE_TEST #include "gmock/gmock.h" diff --git a/test/ostream-test.cc b/test/ostream-test.cc index e5f4785a..a01182d1 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -70,16 +70,16 @@ TEST(ostream_test, format_specs) { EXPECT_EQ(" def", fmt::format("{0:>5}", test_string("def"))); EXPECT_EQ(" def ", fmt::format("{0:^5}", test_string("def"))); EXPECT_EQ("def**", fmt::format("{0:*<5}", test_string("def"))); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:+}"), test_string()), format_error, - "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:-}"), test_string()), format_error, - "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0: }"), test_string()), format_error, - "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:#}"), test_string()), format_error, - "format specifier requires numeric argument"); - EXPECT_THROW_MSG((void)fmt::format(runtime("{0:05}"), test_string()), format_error, - "format specifier requires numeric argument"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:+}"), test_string()), + format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:-}"), test_string()), + format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{0: }"), test_string()), + format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:#}"), test_string()), + format_error, "format specifier requires numeric argument"); + EXPECT_THROW_MSG((void)fmt::format(runtime("{0:05}"), test_string()), + format_error, "format specifier requires numeric argument"); EXPECT_EQ("test ", fmt::format("{0:13}", test_string("test"))); EXPECT_EQ("test ", fmt::format("{0:{1}}", test_string("test"), 13)); EXPECT_EQ("te", fmt::format("{0:.2}", test_string("test"))); diff --git a/test/ranges-odr-test.cc b/test/ranges-odr-test.cc index 9d6cd1ff..031354d3 100644 --- a/test/ranges-odr-test.cc +++ b/test/ranges-odr-test.cc @@ -5,10 +5,9 @@ // // For the license information refer to format.h. -#include "fmt/ranges.h" - #include +#include "fmt/ranges.h" #include "gtest/gtest.h" // call fmt::format from another translation unit to test ODR @@ -16,4 +15,3 @@ TEST(ranges_odr_test, format_vector) { auto v = std::vector{1, 2, 3, 5, 7, 11}; EXPECT_EQ(fmt::format("{}", v), "[1, 2, 3, 5, 7, 11]"); } - diff --git a/test/util.h b/test/util.h index 97e50909..2e58ad95 100644 --- a/test/util.h +++ b/test/util.h @@ -13,8 +13,8 @@ #ifdef FMT_MODULE_TEST import fmt; #else -#include "fmt/os.h" -#endif // FMT_MODULE_TEST +# include "fmt/os.h" +#endif // FMT_MODULE_TEST #ifdef _MSC_VER # define FMT_VSNPRINTF vsprintf_s