style: clang-format applied to last commits to make pre-commit happy

This commit is contained in:
Mateusz Pusz
2023-01-03 14:27:44 +01:00
parent 8644df8a98
commit eec4312e01
21 changed files with 112 additions and 100 deletions

View File

@@ -64,7 +64,8 @@ void print_details(std::string_view description, const Ship& ship)
{ {
const auto waterDensity = si::fps::density::lb_per_ft3<>(62.4); 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("{}\n", description);
std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.length)) std::cout
<< UNITS_STD_FMT::format("{:20} : {}\n", "length", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.length))
<< UNITS_STD_FMT::format("{:20} : {}\n", "draft", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.draft)) << UNITS_STD_FMT::format("{:20} : {}\n", "draft", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.draft))
<< UNITS_STD_FMT::format("{:20} : {}\n", "beam", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.beam)) << UNITS_STD_FMT::format("{:20} : {}\n", "beam", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.beam))
<< UNITS_STD_FMT::format("{:20} : {}\n", "mass", fmt_line<si::fps::mass::lton<>, si::mass::t<>>(ship.mass)) << UNITS_STD_FMT::format("{:20} : {}\n", "mass", fmt_line<si::fps::mass::lton<>, si::mass::t<>>(ship.mass))

View File

@@ -86,8 +86,8 @@ void print(const R& gliders)
std::cout << "- Polar:\n"; std::cout << "- Polar:\n";
for (const auto& p : g.polar) { for (const auto& p : g.polar) {
const auto ratio = units::quantity_cast<units::one>(glide_ratio(g.polar[0])); const auto ratio = units::quantity_cast<units::one>(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, std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v,
units::quantity_cast<units::degree>(asin(1 / ratio))); ratio, units::quantity_cast<units::degree>(asin(1 / ratio)));
} }
std::cout << "\n"; std::cout << "\n";
} }

View File

@@ -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("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, std::cout << UNITS_STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n",
lengthB) lengthA, lengthB)
<< UNITS_STD_FMT::format("lengthB.number( {} ) == lengthA.number( {} ) * conversion_factor( {} )\n", << 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));
} }

View File

@@ -177,8 +177,8 @@ struct UNITS_STD_FMT::formatter<kalman::state<Qs...>> {
if constexpr (sizeof...(Qs) == 1) if constexpr (sizeof...(Qs) == 1)
UNITS_STD_FMT::format_to(to_value_buffer, "{1:%.{0}Q %q}", specs.precision, kalman::get<0>(s)); UNITS_STD_FMT::format_to(to_value_buffer, "{1:%.{0}Q %q}", specs.precision, kalman::get<0>(s));
else if constexpr (sizeof...(Qs) == 2) 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), UNITS_STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision,
kalman::get<1>(s)); kalman::get<0>(s), kalman::get<1>(s));
else else
UNITS_STD_FMT::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, 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));
@@ -223,7 +223,8 @@ struct UNITS_STD_FMT::formatter<kalman::estimation<Q>> {
std::string value_buffer; std::string value_buffer;
auto to_value_buffer = std::back_inserter(value_buffer); auto to_value_buffer = std::back_inserter(value_buffer);
if (specs.precision != -1) { 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 { } else {
UNITS_STD_FMT::format_to(to_value_buffer, "{0:%Q} ± {1:%Q} {0:%q}", q, sqrt(e.uncertainty)); UNITS_STD_FMT::format_to(to_value_buffer, "{0:%Q} ± {1:%Q} {0:%q}", q, sqrt(e.uncertainty));
} }

View File

@@ -34,8 +34,8 @@ using namespace units;
void print_header(const kalman::State auto& initial) void print_header(const kalman::State auto& initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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", std::cout << UNITS_STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured",
"Next Estimate"); "Curr. Estimate", "Next Estimate");
} }
void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current, void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current,

View File

@@ -36,7 +36,8 @@ using namespace units;
void print_header(const kalman::State auto& initial) void print_header(const kalman::State auto& initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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) void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next)

View File

@@ -36,7 +36,8 @@ using namespace units;
void print_header(const kalman::State auto& initial) void print_header(const kalman::State auto& initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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) void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next)

View File

@@ -37,7 +37,8 @@ using namespace units;
void print_header(const kalman::State auto& initial) void print_header(const kalman::State auto& initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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) void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next)

View File

@@ -35,15 +35,15 @@ template<Quantity Q>
void print_header(kalman::estimation<Q> initial) void print_header(kalman::estimation<Q> initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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", std::cout << UNITS_STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured",
"Next Estimate"); "Curr. Estimate", "Next Estimate");
} }
template<Quantity Q, Dimensionless K> template<Quantity Q, Dimensionless K>
void print(auto iteration, K gain, Q measured, kalman::estimation<Q> current, kalman::estimation<Q> next) void print(auto iteration, K gain, Q measured, kalman::estimation<Q> current, kalman::estimation<Q> next)
{ {
std::cout << UNITS_STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured, current, std::cout << UNITS_STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured,
next); current, next);
} }
int main() int main()

View File

@@ -56,8 +56,8 @@ template<QuantityPoint QP>
void print_header(kalman::estimation<QP> initial) void print_header(kalman::estimation<QP> initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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", std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured",
"Next Estimate"); "Curr. Estimate", "Next Estimate");
} }
template<QuantityPoint QP, Dimensionless K> template<QuantityPoint QP, Dimensionless K>

View File

@@ -56,8 +56,8 @@ template<QuantityPoint QP>
void print_header(kalman::estimation<QP> initial) void print_header(kalman::estimation<QP> initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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", std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured",
"Next Estimate"); "Curr. Estimate", "Next Estimate");
} }
template<QuantityPoint QP, Dimensionless K> template<QuantityPoint QP, Dimensionless K>

View File

@@ -56,8 +56,8 @@ template<QuantityPoint QP>
void print_header(kalman::estimation<QP> initial) void print_header(kalman::estimation<QP> initial)
{ {
std::cout << UNITS_STD_FMT::format("Initial: {}\n", 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", std::cout << UNITS_STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured",
"Next Estimate"); "Curr. Estimate", "Next Estimate");
} }
template<QuantityPoint QP, Dimensionless K> template<QuantityPoint QP, Dimensionless K>

View File

@@ -66,7 +66,8 @@ void print_details(std::string_view description, const Ship& ship)
using namespace units::isq::si::fps::literals; using namespace units::isq::si::fps::literals;
const auto waterDensity = 62.4_q_lb_per_ft3; const auto waterDensity = 62.4_q_lb_per_ft3;
std::cout << UNITS_STD_FMT::format("{}\n", description); std::cout << UNITS_STD_FMT::format("{}\n", description);
std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", std::cout
<< UNITS_STD_FMT::format("{:20} : {}\n", "length",
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length)) fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length))
<< UNITS_STD_FMT::format("{:20} : {}\n", "draft", << UNITS_STD_FMT::format("{:20} : {}\n", "draft",
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.draft)) fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.draft))

View File

@@ -86,8 +86,8 @@ void print(const R& gliders)
std::cout << "- Polar:\n"; std::cout << "- Polar:\n";
for (const auto& p : g.polar) { for (const auto& p : g.polar) {
const auto ratio = units::quantity_cast<units::one>(glide_ratio(g.polar[0])); const auto ratio = units::quantity_cast<units::one>(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, std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v,
units::quantity_cast<units::degree>(asin(1 / ratio))); ratio, units::quantity_cast<units::degree>(asin(1 / ratio)));
} }
std::cout << "\n"; std::cout << "\n";
} }

View File

@@ -69,7 +69,8 @@ void print_details(std::string_view description, const Ship& ship)
using namespace units::isq::si::fps::references; using namespace units::isq::si::fps::references;
const auto waterDensity = 62.4 * (lb / ft3); const auto waterDensity = 62.4 * (lb / ft3);
std::cout << UNITS_STD_FMT::format("{}\n", description); std::cout << UNITS_STD_FMT::format("{}\n", description);
std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", std::cout
<< UNITS_STD_FMT::format("{:20} : {}\n", "length",
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length)) fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length))
<< UNITS_STD_FMT::format("{:20} : {}\n", "draft", << UNITS_STD_FMT::format("{:20} : {}\n", "draft",
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.draft)) fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.draft))

View File

@@ -86,8 +86,8 @@ void print(const R& gliders)
std::cout << "- Polar:\n"; std::cout << "- Polar:\n";
for (const auto& p : g.polar) { for (const auto& p : g.polar) {
const auto ratio = units::quantity_cast<units::one>(glide_ratio(g.polar[0])); const auto ratio = units::quantity_cast<units::one>(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, std::cout << UNITS_STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q} ({:%.1Q %q})\n", p.climb, p.v,
units::quantity_cast<units::degree>(asin(1 / ratio))); ratio, units::quantity_cast<units::degree>(asin(1 / ratio)));
} }
std::cout << "\n"; std::cout << "\n";
} }

View File

@@ -493,7 +493,10 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text]
CHECK(UNITS_STD_FMT::format("{:%Q}", length<metre>(std::numeric_limits<double>::quiet_NaN())) == "nan"); CHECK(UNITS_STD_FMT::format("{:%Q}", length<metre>(std::numeric_limits<double>::quiet_NaN())) == "nan");
} }
SECTION("inf") { CHECK(UNITS_STD_FMT::format("{:%Q}", length<metre>(std::numeric_limits<double>::infinity())) == "inf"); } SECTION("inf")
{
CHECK(UNITS_STD_FMT::format("{:%Q}", length<metre>(std::numeric_limits<double>::infinity())) == "inf");
}
SECTION("-inf") SECTION("-inf")
{ {
@@ -695,13 +698,15 @@ TEST_CASE("precision specification for integral representation should throw", "[
{ {
SECTION("full format {:%Q %q} on a quantity") 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")); Catch::Matchers::Message("precision not allowed for integral quantity representation"));
} }
SECTION("value only format {:%Q} on a quantity") 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")); Catch::Matchers::Message("precision not allowed for integral quantity representation"));
} }
} }

View File

@@ -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_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("{}", 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_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 x 10^9]
// CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_au * 1_q_au) == "1 [2237952291797391849 x 10^4] m^2"); // 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") SECTION("unknown scaled unit with reference different than the dimension's coherent unit")