forked from mpusz/mp-units
style: clang-format applied to last commits to make pre-commit happy
This commit is contained in:
@@ -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);
|
||||
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", "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))
|
||||
|
@@ -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<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,
|
||||
units::quantity_cast<units::degree>(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<units::degree>(asin(1 / ratio)));
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -177,8 +177,8 @@ struct UNITS_STD_FMT::formatter<kalman::state<Qs...>> {
|
||||
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));
|
||||
@@ -223,7 +223,8 @@ struct UNITS_STD_FMT::formatter<kalman::estimation<Q>> {
|
||||
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));
|
||||
}
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -35,15 +35,15 @@ template<Quantity Q>
|
||||
void print_header(kalman::estimation<Q> 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<Quantity Q, Dimensionless K>
|
||||
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,
|
||||
next);
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:5%.2Q} | {:8} | {:>16.2} | {:>16.2}\n", iteration, gain, measured,
|
||||
current, next);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -56,8 +56,8 @@ template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> 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<QuantityPoint QP, Dimensionless K>
|
||||
|
@@ -56,8 +56,8 @@ template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> 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<QuantityPoint QP, Dimensionless K>
|
||||
|
@@ -56,8 +56,8 @@ template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> 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<QuantityPoint QP, Dimensionless K>
|
||||
|
@@ -66,7 +66,8 @@ 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",
|
||||
std::cout
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "length",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "draft",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.draft))
|
||||
|
@@ -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<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,
|
||||
units::quantity_cast<units::degree>(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<units::degree>(asin(1 / ratio)));
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
@@ -69,7 +69,8 @@ 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",
|
||||
std::cout
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "length",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "draft",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.draft))
|
||||
|
@@ -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<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,
|
||||
units::quantity_cast<units::degree>(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<units::degree>(asin(1 / ratio)));
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
@@ -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");
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
@@ -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")
|
||||
|
Reference in New Issue
Block a user