From eec4312e012668db5ee040228083d42a72b92a43 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 3 Jan 2023 14:27:44 +0100 Subject: [PATCH] style: clang-format applied to last commits to make pre-commit happy --- example/aliases/foot_pound_second.cpp | 31 ++++++------- example/aliases/glide_computer_example.cpp | 4 +- example/conversion_factor.cpp | 6 +-- example/glide_computer/glide_computer.cpp | 2 +- example/hello_units.cpp | 4 +- example/kalman_filter/kalman.h | 11 ++--- .../kalman_filter/kalman_filter-example_1.cpp | 4 +- .../kalman_filter/kalman_filter-example_2.cpp | 3 +- .../kalman_filter/kalman_filter-example_3.cpp | 3 +- .../kalman_filter/kalman_filter-example_4.cpp | 3 +- .../kalman_filter/kalman_filter-example_5.cpp | 8 ++-- .../kalman_filter/kalman_filter-example_6.cpp | 6 +-- .../kalman_filter/kalman_filter-example_7.cpp | 6 +-- .../kalman_filter/kalman_filter-example_8.cpp | 6 +-- example/literals/foot_pound_second.cpp | 45 ++++++++++--------- example/literals/glide_computer_example.cpp | 4 +- example/references/foot_pound_second.cpp | 45 ++++++++++--------- example/references/glide_computer_example.cpp | 4 +- example/si_constants.cpp | 2 +- test/unit_test/runtime/fmt_test.cpp | 11 +++-- test/unit_test/runtime/fmt_units_test.cpp | 4 +- 21 files changed, 112 insertions(+), 100 deletions(-) diff --git a/example/aliases/foot_pound_second.cpp b/example/aliases/foot_pound_second.cpp index a9d17b86..81a1e584 100644 --- a/example/aliases/foot_pound_second.cpp +++ b/example/aliases/foot_pound_second.cpp @@ -64,21 +64,22 @@ void print_details(std::string_view description, const Ship& ship) { const auto waterDensity = si::fps::density::lb_per_ft3<>(62.4); std::cout << UNITS_STD_FMT::format("{}\n", description); - std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length::m<>>(ship.length)) - << UNITS_STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length::m<>>(ship.draft)) - << UNITS_STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) - << UNITS_STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) - << UNITS_STD_FMT::format("{:20} : {}\n", "speed", - fmt_line, si::speed::km_per_h<>>(ship.speed)) - << UNITS_STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) - << UNITS_STD_FMT::format("{:20} : {}\n", "main guns", - fmt_line, si::length::mm<>>(ship.mainGuns)) - << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing", - fmt_line, si::mass::kg<>>(ship.shellMass)) - << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells at", - fmt_line, si::speed::km_per_h<>>(ship.shellSpeed)) - << UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", - fmt_line, si::volume::l<>>(ship.mass / waterDensity)); + std::cout + << UNITS_STD_FMT::format("{:20} : {}\n", "length", fmt_line, si::length::m<>>(ship.length)) + << UNITS_STD_FMT::format("{:20} : {}\n", "draft", fmt_line, si::length::m<>>(ship.draft)) + << UNITS_STD_FMT::format("{:20} : {}\n", "beam", fmt_line, si::length::m<>>(ship.beam)) + << UNITS_STD_FMT::format("{:20} : {}\n", "mass", fmt_line, si::mass::t<>>(ship.mass)) + << UNITS_STD_FMT::format("{:20} : {}\n", "speed", + fmt_line, si::speed::km_per_h<>>(ship.speed)) + << UNITS_STD_FMT::format("{:20} : {}\n", "power", fmt_line, si::power::kW<>>(ship.power)) + << UNITS_STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length::mm<>>(ship.mainGuns)) + << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass::kg<>>(ship.shellMass)) + << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells at", + fmt_line, si::speed::km_per_h<>>(ship.shellSpeed)) + << UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume::l<>>(ship.mass / waterDensity)); } int main() diff --git a/example/aliases/glide_computer_example.cpp b/example/aliases/glide_computer_example.cpp index cc49e006..75346469 100644 --- a/example/aliases/glide_computer_example.cpp +++ b/example/aliases/glide_computer_example.cpp @@ -86,8 +86,8 @@ void print(const R& gliders) std::cout << "- Polar:\n"; for (const auto& p : g.polar) { const auto ratio = units::quantity_cast(glide_ratio(g.polar[0])); - std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v, ratio, - units::quantity_cast(asin(1 / ratio))); + std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v, + ratio, units::quantity_cast(asin(1 / ratio))); } std::cout << "\n"; } diff --git a/example/conversion_factor.cpp b/example/conversion_factor.cpp index 8a9d5b1e..11980c46 100644 --- a/example/conversion_factor.cpp +++ b/example/conversion_factor.cpp @@ -54,8 +54,8 @@ int main() std::cout << UNITS_STD_FMT::format("therefore ratio lengthA / lengthB == {}\n\n", lengthA / lengthB); - std::cout << UNITS_STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n", lengthA, - lengthB) + std::cout << UNITS_STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n", + lengthA, lengthB) << UNITS_STD_FMT::format("lengthB.number( {} ) == lengthA.number( {} ) * conversion_factor( {} )\n", - lengthB.number(), lengthA.number(), conversion_factor(lengthB, lengthA)); + lengthB.number(), lengthA.number(), conversion_factor(lengthB, lengthA)); } diff --git a/example/glide_computer/glide_computer.cpp b/example/glide_computer/glide_computer.cpp index 2af34b23..3428448d 100644 --- a/example/glide_computer/glide_computer.cpp +++ b/example/glide_computer/glide_computer.cpp @@ -141,7 +141,7 @@ void estimate(timestamp start_ts, const glider& g, const weather& w, const task& const aircraft_tow& at) { std::cout << UNITS_STD_FMT::format("| {:<12} | {:^28} | {:^26} | {:^21} |\n", "Flight phase", "Duration", "Distance", - "Height"); + "Height"); std::cout << UNITS_STD_FMT::format("|{0:-^14}|{0:-^30}|{0:-^28}|{0:-^23}|\n", ""); // ready to takeoff diff --git a/example/hello_units.cpp b/example/hello_units.cpp index 42d6aba2..27481e91 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -52,8 +52,8 @@ int main() #endif constexpr Speed auto v7 = quantity_cast(v6); - std::cout << v1 << '\n'; // 110 km/h - std::cout << v2 << '\n'; // 70 mi/h + std::cout << v1 << '\n'; // 110 km/h + std::cout << v2 << '\n'; // 70 mi/h std::cout << UNITS_STD_FMT::format("{}", v3) << '\n'; // 110 km/h std::cout << UNITS_STD_FMT::format("{:*^14}", v4) << '\n'; // ***70 mi/h**** std::cout << UNITS_STD_FMT::format("{:%Q in %q}", v5) << '\n'; // 30.5556 in m/s diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index b5223238..7a3fa1e4 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -177,11 +177,11 @@ struct UNITS_STD_FMT::formatter> { if constexpr (sizeof...(Qs) == 1) UNITS_STD_FMT::format_to(to_value_buffer, "{1:%.{0}Q %q}", specs.precision, kalman::get<0>(s)); else if constexpr (sizeof...(Qs) == 2) - UNITS_STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), - kalman::get<1>(s)); + UNITS_STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, + kalman::get<0>(s), kalman::get<1>(s)); else UNITS_STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, - kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); + kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s)); } else { if constexpr (sizeof...(Qs) == 1) UNITS_STD_FMT::format_to(to_value_buffer, "{}", kalman::get<0>(s)); @@ -189,7 +189,7 @@ struct UNITS_STD_FMT::formatter> { UNITS_STD_FMT::format_to(to_value_buffer, "{{ {}, {} }}", kalman::get<0>(s), kalman::get<1>(s)); else UNITS_STD_FMT::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s), - kalman::get<2>(s)); + kalman::get<2>(s)); } std::string global_format_buffer; @@ -223,7 +223,8 @@ struct UNITS_STD_FMT::formatter> { std::string value_buffer; auto to_value_buffer = std::back_inserter(value_buffer); if (specs.precision != -1) { - UNITS_STD_FMT::format_to(to_value_buffer, "{0:%.{2}Q} ± {1:%.{2}Q} {0:%q}", q, sqrt(e.uncertainty), specs.precision); + UNITS_STD_FMT::format_to(to_value_buffer, "{0:%.{2}Q} ± {1:%.{2}Q} {0:%q}", q, sqrt(e.uncertainty), + specs.precision); } else { UNITS_STD_FMT::format_to(to_value_buffer, "{0:%Q} ± {1:%Q} {0:%q}", q, sqrt(e.uncertainty)); } diff --git a/example/kalman_filter/kalman_filter-example_1.cpp b/example/kalman_filter/kalman_filter-example_1.cpp index 7352acb8..bd122099 100644 --- a/example/kalman_filter/kalman_filter-example_1.cpp +++ b/example/kalman_filter/kalman_filter-example_1.cpp @@ -34,8 +34,8 @@ using namespace units; void print_header(const kalman::State auto& initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured", "Curr. Estimate", - "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured", + "Curr. Estimate", "Next Estimate"); } void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current, diff --git a/example/kalman_filter/kalman_filter-example_2.cpp b/example/kalman_filter/kalman_filter-example_2.cpp index 7eb6f417..29485c31 100644 --- a/example/kalman_filter/kalman_filter-example_2.cpp +++ b/example/kalman_filter/kalman_filter-example_2.cpp @@ -36,7 +36,8 @@ using namespace units; void print_header(const kalman::State auto& initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>8} | {:>23} | {:>23}\n", "N", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>8} | {:>23} | {:>23}\n", "N", "Measured", "Curr. Estimate", + "Next Estimate"); } void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next) diff --git a/example/kalman_filter/kalman_filter-example_3.cpp b/example/kalman_filter/kalman_filter-example_3.cpp index eb442ee4..adbf5c70 100644 --- a/example/kalman_filter/kalman_filter-example_3.cpp +++ b/example/kalman_filter/kalman_filter-example_3.cpp @@ -36,7 +36,8 @@ using namespace units; void print_header(const kalman::State auto& initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>8} | {:>24} | {:>24}\n", "N", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>8} | {:>24} | {:>24}\n", "N", "Measured", "Curr. Estimate", + "Next Estimate"); } void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next) diff --git a/example/kalman_filter/kalman_filter-example_4.cpp b/example/kalman_filter/kalman_filter-example_4.cpp index d531f537..bbb4ab35 100644 --- a/example/kalman_filter/kalman_filter-example_4.cpp +++ b/example/kalman_filter/kalman_filter-example_4.cpp @@ -37,7 +37,8 @@ using namespace units; void print_header(const kalman::State auto& initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>8} | {:>35} | {:>35}\n", "N", "Measured", "Curr. Estimate", "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>8} | {:>35} | {:>35}\n", "N", "Measured", "Curr. Estimate", + "Next Estimate"); } void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next) diff --git a/example/kalman_filter/kalman_filter-example_5.cpp b/example/kalman_filter/kalman_filter-example_5.cpp index 333e970a..d899736d 100644 --- a/example/kalman_filter/kalman_filter-example_5.cpp +++ b/example/kalman_filter/kalman_filter-example_5.cpp @@ -35,15 +35,15 @@ template void print_header(kalman::estimation initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", - "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured", + "Curr. Estimate", "Next Estimate"); } template void print(auto iteration, K gain, Q measured, kalman::estimation current, kalman::estimation next) { - std::cout << UNITS_STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured, current, - next); + std::cout << UNITS_STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured, + current, next); } int main() diff --git a/example/kalman_filter/kalman_filter-example_6.cpp b/example/kalman_filter/kalman_filter-example_6.cpp index 965a245a..4293b5f3 100644 --- a/example/kalman_filter/kalman_filter-example_6.cpp +++ b/example/kalman_filter/kalman_filter-example_6.cpp @@ -56,15 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", - "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", + "Curr. Estimate", "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { std::cout << UNITS_STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, - measured.relative(), current, next); + measured.relative(), current, next); } int main() diff --git a/example/kalman_filter/kalman_filter-example_7.cpp b/example/kalman_filter/kalman_filter-example_7.cpp index b5bd11ee..b44b0c78 100644 --- a/example/kalman_filter/kalman_filter-example_7.cpp +++ b/example/kalman_filter/kalman_filter-example_7.cpp @@ -56,15 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate", - "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", + "Curr. Estimate", "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { std::cout << UNITS_STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain, - measured.relative(), current, next); + measured.relative(), current, next); } int main() diff --git a/example/kalman_filter/kalman_filter-example_8.cpp b/example/kalman_filter/kalman_filter-example_8.cpp index edd20190..f0d0b103 100644 --- a/example/kalman_filter/kalman_filter-example_8.cpp +++ b/example/kalman_filter/kalman_filter-example_8.cpp @@ -56,15 +56,15 @@ template void print_header(kalman::estimation initial) { std::cout << UNITS_STD_FMT::format("Initial: {}\n", initial); - std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate", - "Next Estimate"); + std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured", + "Curr. Estimate", "Next Estimate"); } template void print(auto iteration, K gain, QP measured, kalman::estimation current, kalman::estimation next) { std::cout << UNITS_STD_FMT::format("{:2} | {:7%.3Q} | {:10%.3Q %q} | {:>16.2} | {:>16.2}\n", iteration, gain, - measured.relative(), current, next); + measured.relative(), current, next); } int main() diff --git a/example/literals/foot_pound_second.cpp b/example/literals/foot_pound_second.cpp index 417a00c1..40f1be0f 100644 --- a/example/literals/foot_pound_second.cpp +++ b/example/literals/foot_pound_second.cpp @@ -66,28 +66,29 @@ void print_details(std::string_view description, const Ship& ship) using namespace units::isq::si::fps::literals; const auto waterDensity = 62.4_q_lb_per_ft3; std::cout << UNITS_STD_FMT::format("{}\n", description); - std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", - fmt_line, si::length>(ship.length)) - << UNITS_STD_FMT::format("{:20} : {}\n", "draft", - fmt_line, si::length>(ship.draft)) - << UNITS_STD_FMT::format("{:20} : {}\n", "beam", - fmt_line, si::length>(ship.beam)) - << UNITS_STD_FMT::format("{:20} : {}\n", "mass", - fmt_line, si::mass>(ship.mass)) - << UNITS_STD_FMT::format( - "{:20} : {}\n", "speed", - fmt_line, si::speed>(ship.speed)) - << UNITS_STD_FMT::format("{:20} : {}\n", "power", - fmt_line, si::power>(ship.power)) - << UNITS_STD_FMT::format("{:20} : {}\n", "main guns", - fmt_line, si::length>(ship.mainGuns)) - << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing", - fmt_line, si::mass>(ship.shellMass)) - << UNITS_STD_FMT::format( - "{:20} : {}\n", "fire shells at", - fmt_line, si::speed>(ship.shellSpeed)) - << UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", - fmt_line, si::volume>(ship.mass / waterDensity)); + std::cout + << UNITS_STD_FMT::format("{:20} : {}\n", "length", + fmt_line, si::length>(ship.length)) + << UNITS_STD_FMT::format("{:20} : {}\n", "draft", + fmt_line, si::length>(ship.draft)) + << UNITS_STD_FMT::format("{:20} : {}\n", "beam", + fmt_line, si::length>(ship.beam)) + << UNITS_STD_FMT::format("{:20} : {}\n", "mass", + fmt_line, si::mass>(ship.mass)) + << UNITS_STD_FMT::format( + "{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) + << UNITS_STD_FMT::format("{:20} : {}\n", "power", + fmt_line, si::power>(ship.power)) + << UNITS_STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length>(ship.mainGuns)) + << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass>(ship.shellMass)) + << UNITS_STD_FMT::format( + "{:20} : {}\n", "fire shells at", + fmt_line, si::speed>(ship.shellSpeed)) + << UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume>(ship.mass / waterDensity)); } int main() diff --git a/example/literals/glide_computer_example.cpp b/example/literals/glide_computer_example.cpp index a8723611..10e36f13 100644 --- a/example/literals/glide_computer_example.cpp +++ b/example/literals/glide_computer_example.cpp @@ -86,8 +86,8 @@ void print(const R& gliders) std::cout << "- Polar:\n"; for (const auto& p : g.polar) { const auto ratio = units::quantity_cast(glide_ratio(g.polar[0])); - std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v, ratio, - units::quantity_cast(asin(1 / ratio))); + std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v, + ratio, units::quantity_cast(asin(1 / ratio))); } std::cout << "\n"; } diff --git a/example/references/foot_pound_second.cpp b/example/references/foot_pound_second.cpp index 3a7f6758..13498382 100644 --- a/example/references/foot_pound_second.cpp +++ b/example/references/foot_pound_second.cpp @@ -69,28 +69,29 @@ void print_details(std::string_view description, const Ship& ship) using namespace units::isq::si::fps::references; const auto waterDensity = 62.4 * (lb / ft3); std::cout << UNITS_STD_FMT::format("{}\n", description); - std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", - fmt_line, si::length>(ship.length)) - << UNITS_STD_FMT::format("{:20} : {}\n", "draft", - fmt_line, si::length>(ship.draft)) - << UNITS_STD_FMT::format("{:20} : {}\n", "beam", - fmt_line, si::length>(ship.beam)) - << UNITS_STD_FMT::format("{:20} : {}\n", "mass", - fmt_line, si::mass>(ship.mass)) - << UNITS_STD_FMT::format( - "{:20} : {}\n", "speed", - fmt_line, si::speed>(ship.speed)) - << UNITS_STD_FMT::format("{:20} : {}\n", "power", - fmt_line, si::power>(ship.power)) - << UNITS_STD_FMT::format("{:20} : {}\n", "main guns", - fmt_line, si::length>(ship.mainGuns)) - << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing", - fmt_line, si::mass>(ship.shellMass)) - << UNITS_STD_FMT::format( - "{:20} : {}\n", "fire shells at", - fmt_line, si::speed>(ship.shellSpeed)) - << UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", - fmt_line, si::volume>(ship.mass / waterDensity)); + std::cout + << UNITS_STD_FMT::format("{:20} : {}\n", "length", + fmt_line, si::length>(ship.length)) + << UNITS_STD_FMT::format("{:20} : {}\n", "draft", + fmt_line, si::length>(ship.draft)) + << UNITS_STD_FMT::format("{:20} : {}\n", "beam", + fmt_line, si::length>(ship.beam)) + << UNITS_STD_FMT::format("{:20} : {}\n", "mass", + fmt_line, si::mass>(ship.mass)) + << UNITS_STD_FMT::format( + "{:20} : {}\n", "speed", + fmt_line, si::speed>(ship.speed)) + << UNITS_STD_FMT::format("{:20} : {}\n", "power", + fmt_line, si::power>(ship.power)) + << UNITS_STD_FMT::format("{:20} : {}\n", "main guns", + fmt_line, si::length>(ship.mainGuns)) + << UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing", + fmt_line, si::mass>(ship.shellMass)) + << UNITS_STD_FMT::format( + "{:20} : {}\n", "fire shells at", + fmt_line, si::speed>(ship.shellSpeed)) + << UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", + fmt_line, si::volume>(ship.mass / waterDensity)); } int main() diff --git a/example/references/glide_computer_example.cpp b/example/references/glide_computer_example.cpp index 073a5df9..f79981fb 100644 --- a/example/references/glide_computer_example.cpp +++ b/example/references/glide_computer_example.cpp @@ -86,8 +86,8 @@ void print(const R& gliders) std::cout << "- Polar:\n"; for (const auto& p : g.polar) { const auto ratio = units::quantity_cast(glide_ratio(g.polar[0])); - std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v, ratio, - units::quantity_cast(asin(1 / ratio))); + std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v, + ratio, units::quantity_cast(asin(1 / ratio))); } std::cout << "\n"; } diff --git a/example/si_constants.cpp b/example/si_constants.cpp index 2a496fe3..dc0a203d 100644 --- a/example/si_constants.cpp +++ b/example/si_constants.cpp @@ -30,7 +30,7 @@ int main() std::cout << "The seven defining constants of the SI and the seven corresponding units they define:\n"; std::cout << UNITS_STD_FMT::format("- hyperfine transition frequency of Cs: {:%.0Q %q}\n", - hyperfine_structure_transition_frequency<>); + hyperfine_structure_transition_frequency<>); std::cout << UNITS_STD_FMT::format("- speed of light in vacuum: {:%.0Q %q}\n", speed_of_light<>); std::cout << UNITS_STD_FMT::format("- Planck constant: {}\n", planck_constant<>); std::cout << UNITS_STD_FMT::format("- elementary charge: {}\n", elementary_charge<>); diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index acacb07a..22e73418 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -493,7 +493,10 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text] CHECK(UNITS_STD_FMT::format("{:%Q}", length(std::numeric_limits::quiet_NaN())) == "nan"); } - SECTION("inf") { CHECK(UNITS_STD_FMT::format("{:%Q}", length(std::numeric_limits::infinity())) == "inf"); } + SECTION("inf") + { + CHECK(UNITS_STD_FMT::format("{:%Q}", length(std::numeric_limits::infinity())) == "inf"); + } SECTION("-inf") { @@ -695,13 +698,15 @@ TEST_CASE("precision specification for integral representation should throw", "[ { SECTION("full format {:%Q %q} on a quantity") { - REQUIRE_THROWS_MATCHES(UNITS_STD_FMT::vformat("{:%.1Q %q}", UNITS_STD_FMT::make_format_args(1_q_m)), UNITS_STD_FMT::format_error, + REQUIRE_THROWS_MATCHES(UNITS_STD_FMT::vformat("{:%.1Q %q}", UNITS_STD_FMT::make_format_args(1_q_m)), + UNITS_STD_FMT::format_error, Catch::Matchers::Message("precision not allowed for integral quantity representation")); } SECTION("value only format {:%Q} on a quantity") { - REQUIRE_THROWS_MATCHES(UNITS_STD_FMT::vformat("{:%.1Q}", UNITS_STD_FMT::make_format_args(1_q_m)), UNITS_STD_FMT::format_error, + REQUIRE_THROWS_MATCHES(UNITS_STD_FMT::vformat("{:%.1Q}", UNITS_STD_FMT::make_format_args(1_q_m)), + UNITS_STD_FMT::format_error, Catch::Matchers::Message("precision not allowed for integral quantity representation")); } } diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 8abba817..f238dfee 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -320,8 +320,8 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") // CHECK(UNITS_STD_FMT::format("{}", 1_q_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³"); // CHECK(UNITS_STD_FMT::format("{}", 1_q_au * 1_q_au) == "1 [2237952291797391849 × 10⁴] m²"); // - // CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 x 10^9] m^3"); - // CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_au * 1_q_au) == "1 [2237952291797391849 x 10^4] m^2"); + // CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 x 10^9] + // m^3"); CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_au * 1_q_au) == "1 [2237952291797391849 x 10^4] m^2"); } SECTION("unknown scaled unit with reference different than the dimension's coherent unit")