mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-09 07:04:27 +02:00
refactor macros to start with UNITS_ and fix an MSVC issue with FMT_THROW
This commit is contained in:
@@ -100,9 +100,9 @@ int main()
|
||||
const Time auto fill_time_left = (height / fill_level - 1) * fill_time;
|
||||
|
||||
std::cout << "mp-units box example...\n";
|
||||
std::cout << STD_FMT::format("fill height at {} = {} ({} full)\n", fill_time, fill_level, fill_percent);
|
||||
std::cout << STD_FMT::format("spare_capacity at {} = {}\n", fill_time, spare_capacity);
|
||||
std::cout << STD_FMT::format("input flow rate after {} = {}\n", fill_time, input_flow_rate);
|
||||
std::cout << STD_FMT::format("float rise rate = {}\n", float_rise_rate);
|
||||
std::cout << STD_FMT::format("box full E.T.A. at current flow rate = {}\n", fill_time_left);
|
||||
std::cout << UNITS_STD_FMT::format("fill height at {} = {} ({} full)\n", fill_time, fill_level, fill_percent);
|
||||
std::cout << UNITS_STD_FMT::format("spare_capacity at {} = {}\n", fill_time, spare_capacity);
|
||||
std::cout << UNITS_STD_FMT::format("input flow rate after {} = {}\n", fill_time, input_flow_rate);
|
||||
std::cout << UNITS_STD_FMT::format("float rise rate = {}\n", float_rise_rate);
|
||||
std::cout << UNITS_STD_FMT::format("box full E.T.A. at current flow rate = {}\n", fill_time_left);
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ void calcs_comparison()
|
||||
length::fm<float> L1A = fm<>(2.f);
|
||||
length::fm<float> L2A = fm<>(3.f);
|
||||
length::fm<float> LrA = L1A + L2A;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA);
|
||||
|
||||
std::cout << "The single unit method must convert large\n"
|
||||
"or small values in other units to the base unit.\n"
|
||||
@@ -124,17 +124,17 @@ void calcs_comparison()
|
||||
length::m<float> L1B = L1A;
|
||||
length::m<float> L2B = L2A;
|
||||
length::m<float> LrB = L1B + L2B;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB);
|
||||
|
||||
std::cout << "In multiplication and division:\n\n";
|
||||
|
||||
area::fm2<float> ArA = L1A * L2A;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA);
|
||||
|
||||
std::cout << "similar problems arise\n\n";
|
||||
|
||||
area::m2<float> ArB = L1B * L2B;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -56,28 +56,28 @@ struct Ship {
|
||||
template<class... Args, units::Quantity Q>
|
||||
auto fmt_line(const Q a)
|
||||
{
|
||||
return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast<Args>(a)) + ...);
|
||||
return UNITS_STD_FMT::format("{:22}", a) + (UNITS_STD_FMT::format(",{:20}", units::quantity_cast<Args>(a)) + ...);
|
||||
}
|
||||
|
||||
// Print the ship details in the units as defined in the Ship struct, in other si::imperial units, and in SI
|
||||
void print_details(std::string_view description, const Ship& ship)
|
||||
{
|
||||
const auto waterDensity = si::fps::density::lb_per_ft3<>(62.4);
|
||||
std::cout << STD_FMT::format("{}\n", description);
|
||||
std::cout << STD_FMT::format("{:20} : {}\n", "length", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.length))
|
||||
<< STD_FMT::format("{:20} : {}\n", "draft", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.draft))
|
||||
<< STD_FMT::format("{:20} : {}\n", "beam", fmt_line<si::fps::length::yd<>, si::length::m<>>(ship.beam))
|
||||
<< STD_FMT::format("{:20} : {}\n", "mass", fmt_line<si::fps::mass::lton<>, si::mass::t<>>(ship.mass))
|
||||
<< STD_FMT::format("{:20} : {}\n", "speed",
|
||||
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))
|
||||
<< 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))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "speed",
|
||||
fmt_line<si::international::speed::kn<>, si::speed::km_per_h<>>(ship.speed))
|
||||
<< STD_FMT::format("{:20} : {}\n", "power", fmt_line<si::fps::power::hp<>, si::power::kW<>>(ship.power))
|
||||
<< STD_FMT::format("{:20} : {}\n", "main guns",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "power", fmt_line<si::fps::power::hp<>, si::power::kW<>>(ship.power))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "main guns",
|
||||
fmt_line<si::fps::length::in<>, si::length::mm<>>(ship.mainGuns))
|
||||
<< STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
fmt_line<si::fps::mass::lton<>, si::mass::kg<>>(ship.shellMass))
|
||||
<< STD_FMT::format("{:20} : {}\n", "fire shells at",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "fire shells at",
|
||||
fmt_line<si::fps::speed::mph<>, si::speed::km_per_h<>>(ship.shellSpeed))
|
||||
<< STD_FMT::format("{:20} : {}\n", "volume underwater",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater",
|
||||
fmt_line<si::volume::m3<>, si::volume::l<>>(ship.mass / waterDensity));
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,7 @@ 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 << 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, ratio,
|
||||
units::quantity_cast<units::degree>(asin(1 / ratio)));
|
||||
}
|
||||
std::cout << "\n";
|
||||
@@ -102,8 +102,8 @@ void print(const R& conditions)
|
||||
for (const auto& c : conditions) {
|
||||
std::cout << "- " << c.first << "\n";
|
||||
const auto& w = c.second;
|
||||
std::cout << " * Cloud base: " << STD_FMT::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << STD_FMT::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << " * Cloud base: " << UNITS_STD_FMT::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << UNITS_STD_FMT::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ void print(const R& waypoints)
|
||||
std::cout << "Waypoints:\n";
|
||||
std::cout << "==========\n";
|
||||
for (const auto& w : waypoints)
|
||||
std::cout << STD_FMT::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << UNITS_STD_FMT::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -126,12 +126,12 @@ void print(const task& t)
|
||||
|
||||
std::cout << "- Start: " << t.get_start().name << "\n";
|
||||
std::cout << "- Finish: " << t.get_finish().name << "\n";
|
||||
std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
std::cout << "- Length: " << UNITS_STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
|
||||
std::cout << "- Legs: "
|
||||
<< "\n";
|
||||
for (const auto& l : t.get_legs())
|
||||
std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << UNITS_STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void print(const safety& s)
|
||||
{
|
||||
std::cout << "Safety:\n";
|
||||
std::cout << "=======\n";
|
||||
std::cout << "- Min AGL separation: " << STD_FMT::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "- Min AGL separation: " << UNITS_STD_FMT::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ void print(const aircraft_tow& tow)
|
||||
std::cout << "Tow:\n";
|
||||
std::cout << "====\n";
|
||||
std::cout << "- Type: aircraft\n";
|
||||
std::cout << "- Height: " << STD_FMT::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << STD_FMT::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "- Height: " << UNITS_STD_FMT::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << UNITS_STD_FMT::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ void example()
|
||||
for (const auto& c : weather_conditions) {
|
||||
std::string txt = "Scenario: Glider = " + g.name + ", Weather = " + c.first;
|
||||
std::cout << txt << "\n";
|
||||
std::cout << STD_FMT::format("{0:=^{1}}\n\n", "", txt.size());
|
||||
std::cout << UNITS_STD_FMT::format("{0:=^{1}}\n\n", "", txt.size());
|
||||
|
||||
estimate(start_time, g, c.second, t, sfty, tow);
|
||||
|
||||
|
@@ -36,7 +36,7 @@ std::ostream& operator<<(std::ostream& os, const vector<ET, OT>& v)
|
||||
{
|
||||
os << "|";
|
||||
for (auto i = 0U; i < v.size(); ++i) {
|
||||
os << STD_FMT::format(" {:>9}", v(i));
|
||||
os << UNITS_STD_FMT::format(" {:>9}", v(i));
|
||||
}
|
||||
os << " |";
|
||||
return os;
|
||||
@@ -48,7 +48,7 @@ std::ostream& operator<<(std::ostream& os, const matrix<ET, OT>& v)
|
||||
for (auto i = 0U; i < v.rows(); ++i) {
|
||||
os << "|";
|
||||
for (auto j = 0U; j < v.columns(); ++j) {
|
||||
os << STD_FMT::format(" {:>9}", v(i, j));
|
||||
os << UNITS_STD_FMT::format(" {:>9}", v(i, j));
|
||||
}
|
||||
os << (i != v.rows() - 1U ? " |\n" : " |");
|
||||
}
|
||||
|
@@ -49,13 +49,13 @@ int main()
|
||||
constexpr length<metre> lengthA(2.0);
|
||||
constexpr length<millimetre> lengthB = lengthA;
|
||||
|
||||
std::cout << STD_FMT::format("lengthA( {} ) and lengthB( {} )\n", lengthA, lengthB)
|
||||
std::cout << UNITS_STD_FMT::format("lengthA( {} ) and lengthB( {} )\n", lengthA, lengthB)
|
||||
<< "represent the same length in different units.\n\n";
|
||||
|
||||
std::cout << 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 << 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", lengthA,
|
||||
lengthB)
|
||||
<< 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));
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ using namespace glide_computer;
|
||||
void print(std::string_view phase_name, timestamp start_ts, const glide_computer::flight_point& point,
|
||||
const glide_computer::flight_point& new_point)
|
||||
{
|
||||
std::cout << STD_FMT::format(
|
||||
std::cout << UNITS_STD_FMT::format(
|
||||
"| {:<12} | {:>9%.1Q %q} (Total: {:>9%.1Q %q}) | {:>8%.1Q %q} (Total: {:>8%.1Q %q}) | {:>7%.0Q %q} ({:>6%.0Q %q}) "
|
||||
"|\n",
|
||||
phase_name, quantity_cast<si::minute>(new_point.ts - point.ts), quantity_cast<si::minute>(new_point.ts - start_ts),
|
||||
@@ -140,9 +140,9 @@ namespace glide_computer {
|
||||
void estimate(timestamp start_ts, const glider& g, const weather& w, const task& t, const safety& s,
|
||||
const aircraft_tow& at)
|
||||
{
|
||||
std::cout << STD_FMT::format("| {:<12} | {:^28} | {:^26} | {:^21} |\n", "Flight phase", "Duration", "Distance",
|
||||
std::cout << UNITS_STD_FMT::format("| {:<12} | {:^28} | {:^26} | {:^21} |\n", "Flight phase", "Duration", "Distance",
|
||||
"Height");
|
||||
std::cout << STD_FMT::format("|{0:-^14}|{0:-^30}|{0:-^28}|{0:-^23}|\n", "");
|
||||
std::cout << UNITS_STD_FMT::format("|{0:-^14}|{0:-^30}|{0:-^28}|{0:-^23}|\n", "");
|
||||
|
||||
// ready to takeoff
|
||||
flight_point pos = takeoff(start_ts, t);
|
||||
|
@@ -108,21 +108,21 @@ class std::numeric_limits<geographic::longitude<T>> : public numeric_limits<T> {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct STD_FMT::formatter<geographic::latitude<T>> : formatter<T> {
|
||||
struct UNITS_STD_FMT::formatter<geographic::latitude<T>> : formatter<T> {
|
||||
template<typename FormatContext>
|
||||
auto format(geographic::latitude<T> lat, FormatContext& ctx)
|
||||
{
|
||||
STD_FMT::format_to(ctx.out(), "{}", lat > geographic::latitude<T>::zero() ? 'N' : 'S');
|
||||
UNITS_STD_FMT::format_to(ctx.out(), "{}", lat > geographic::latitude<T>::zero() ? 'N' : 'S');
|
||||
return formatter<T>::format(lat > geographic::latitude<T>::zero() ? lat.number() : -lat.number(), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct STD_FMT::formatter<geographic::longitude<T>> : formatter<T> {
|
||||
struct UNITS_STD_FMT::formatter<geographic::longitude<T>> : formatter<T> {
|
||||
template<typename FormatContext>
|
||||
auto format(geographic::longitude<T> lon, FormatContext& ctx)
|
||||
{
|
||||
STD_FMT::format_to(ctx.out(), "{}", lon > geographic::longitude<T>::zero() ? 'E' : 'W');
|
||||
UNITS_STD_FMT::format_to(ctx.out(), "{}", lon > geographic::longitude<T>::zero() ? 'E' : 'W');
|
||||
return formatter<T>::format(lon > geographic::longitude<T>::zero() ? lon.number() : -lon.number(), ctx);
|
||||
}
|
||||
};
|
||||
|
@@ -57,7 +57,7 @@
|
||||
// - flight path exactly on a shortest possible line to destination
|
||||
|
||||
template<units::QuantityKind QK>
|
||||
struct STD_FMT::formatter<QK> : formatter<typename QK::quantity_type> {
|
||||
struct UNITS_STD_FMT::formatter<QK> : formatter<typename QK::quantity_type> {
|
||||
template<typename FormatContext>
|
||||
auto format(const QK& v, FormatContext& ctx)
|
||||
{
|
||||
@@ -105,12 +105,12 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
|
||||
} // namespace glide_computer
|
||||
|
||||
template<>
|
||||
struct STD_FMT::formatter<glide_computer::altitude> : formatter<units::isq::si::length<units::isq::si::metre>> {
|
||||
struct UNITS_STD_FMT::formatter<glide_computer::altitude> : formatter<units::isq::si::length<units::isq::si::metre>> {
|
||||
template<typename FormatContext>
|
||||
auto format(glide_computer::altitude a, FormatContext& ctx)
|
||||
{
|
||||
formatter<units::isq::si::length<units::isq::si::metre>>::format(a.relative().common(), ctx);
|
||||
return STD_FMT::format_to(ctx.out(), " AMSL");
|
||||
return UNITS_STD_FMT::format_to(ctx.out(), " AMSL");
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -54,9 +54,9 @@ int main()
|
||||
|
||||
std::cout << v1 << '\n'; // 110 km/h
|
||||
std::cout << v2 << '\n'; // 70 mi/h
|
||||
std::cout << STD_FMT::format("{}", v3) << '\n'; // 110 km/h
|
||||
std::cout << STD_FMT::format("{:*^14}", v4) << '\n'; // ***70 mi/h****
|
||||
std::cout << STD_FMT::format("{:%Q in %q}", v5) << '\n'; // 30.5556 in m/s
|
||||
std::cout << STD_FMT::format("{0:%Q} in {0:%q}", v6) << '\n'; // 31.2928 in m/s
|
||||
std::cout << STD_FMT::format("{:%Q}", v7) << '\n'; // 31
|
||||
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
|
||||
std::cout << UNITS_STD_FMT::format("{0:%Q} in {0:%q}", v6) << '\n'; // 31.2928 in m/s
|
||||
std::cout << UNITS_STD_FMT::format("{:%Q}", v7) << '\n'; // 31
|
||||
}
|
||||
|
@@ -161,7 +161,7 @@ constexpr Q covariance_extrapolation(Q uncertainty, Q process_noise_variance)
|
||||
} // namespace kalman
|
||||
|
||||
template<typename... Qs>
|
||||
struct STD_FMT::formatter<kalman::state<Qs...>> {
|
||||
struct UNITS_STD_FMT::formatter<kalman::state<Qs...>> {
|
||||
constexpr auto parse(format_parse_context& ctx)
|
||||
{
|
||||
units::detail::dynamic_specs_handler handler(specs, ctx);
|
||||
@@ -175,20 +175,20 @@ struct STD_FMT::formatter<kalman::state<Qs...>> {
|
||||
auto to_value_buffer = std::back_inserter(value_buffer);
|
||||
if (specs.precision != -1) {
|
||||
if constexpr (sizeof...(Qs) == 1)
|
||||
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)
|
||||
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<0>(s),
|
||||
kalman::get<1>(s));
|
||||
else
|
||||
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));
|
||||
} else {
|
||||
if constexpr (sizeof...(Qs) == 1)
|
||||
STD_FMT::format_to(to_value_buffer, "{}", kalman::get<0>(s));
|
||||
UNITS_STD_FMT::format_to(to_value_buffer, "{}", kalman::get<0>(s));
|
||||
else if constexpr (sizeof...(Qs) == 2)
|
||||
STD_FMT::format_to(to_value_buffer, "{{ {}, {} }}", kalman::get<0>(s), kalman::get<1>(s));
|
||||
UNITS_STD_FMT::format_to(to_value_buffer, "{{ {}, {} }}", kalman::get<0>(s), kalman::get<1>(s));
|
||||
else
|
||||
STD_FMT::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s),
|
||||
UNITS_STD_FMT::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s),
|
||||
kalman::get<2>(s));
|
||||
}
|
||||
|
||||
@@ -196,14 +196,14 @@ struct STD_FMT::formatter<kalman::state<Qs...>> {
|
||||
units::detail::quantity_global_format_specs<char> global_specs = {specs.fill, specs.align, specs.width};
|
||||
units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
|
||||
|
||||
return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer));
|
||||
return UNITS_STD_FMT::vformat_to(ctx.out(), global_format_buffer, UNITS_STD_FMT::make_format_args(value_buffer));
|
||||
}
|
||||
private:
|
||||
units::detail::dynamic_format_specs<char> specs;
|
||||
};
|
||||
|
||||
template<typename Q>
|
||||
struct STD_FMT::formatter<kalman::estimation<Q>> {
|
||||
struct UNITS_STD_FMT::formatter<kalman::estimation<Q>> {
|
||||
constexpr auto parse(format_parse_context& ctx)
|
||||
{
|
||||
units::detail::dynamic_specs_handler handler(specs, ctx);
|
||||
@@ -223,16 +223,16 @@ struct STD_FMT::formatter<kalman::estimation<Q>> {
|
||||
std::string value_buffer;
|
||||
auto to_value_buffer = std::back_inserter(value_buffer);
|
||||
if (specs.precision != -1) {
|
||||
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 {
|
||||
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));
|
||||
}
|
||||
|
||||
std::string global_format_buffer;
|
||||
units::detail::quantity_global_format_specs<char> global_specs = {specs.fill, specs.align, specs.width};
|
||||
units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
|
||||
|
||||
return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer));
|
||||
return UNITS_STD_FMT::vformat_to(ctx.out(), global_format_buffer, UNITS_STD_FMT::make_format_args(value_buffer));
|
||||
}
|
||||
private:
|
||||
units::detail::dynamic_format_specs<char> specs;
|
||||
|
@@ -33,15 +33,15 @@ using namespace units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>9} | {:>8} | {:>14} | {:>14}\n", "N", "Gain", "Measured", "Curr. Estimate",
|
||||
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");
|
||||
}
|
||||
|
||||
void print(auto iteration, Dimensionless auto gain, Quantity auto measured, const kalman::State auto& current,
|
||||
const kalman::State auto& next)
|
||||
{
|
||||
std::cout << STD_FMT::format("{:2} | {:9} | {:8} | {:14} | {:14}\n", iteration, gain, measured, current, next);
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:9} | {:8} | {:14} | {:14}\n", iteration, gain, measured, current, next);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -35,13 +35,13 @@ using namespace units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>8} | {:>23} | {:>23}\n", "N", "Measured", "Curr. Estimate", "Next Estimate");
|
||||
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");
|
||||
}
|
||||
|
||||
void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next)
|
||||
{
|
||||
std::cout << STD_FMT::format("{:2} | {:8} | {:.1} | {:.1}\n", iteration, measured, current, next);
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:8} | {:.1} | {:.1}\n", iteration, measured, current, next);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -35,13 +35,13 @@ using namespace units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>8} | {:>24} | {:>24}\n", "N", "Measured", "Curr. Estimate", "Next Estimate");
|
||||
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");
|
||||
}
|
||||
|
||||
void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next)
|
||||
{
|
||||
std::cout << STD_FMT::format("{:2} | {:8} | {:>24.1} | {:>24.1}\n", iteration, measured, current, next);
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:8} | {:>24.1} | {:>24.1}\n", iteration, measured, current, next);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -36,13 +36,13 @@ using namespace units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>8} | {:>35} | {:>35}\n", "N", "Measured", "Curr. Estimate", "Next Estimate");
|
||||
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");
|
||||
}
|
||||
|
||||
void print(auto iteration, Quantity auto measured, const kalman::State auto& current, const kalman::State auto& next)
|
||||
{
|
||||
std::cout << STD_FMT::format("{:2} | {:8} | {:>35.1} | {:>35.1}\n", iteration, measured, current, next);
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:8} | {:>35.1} | {:>35.1}\n", iteration, measured, current, next);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -34,15 +34,15 @@ using namespace units;
|
||||
template<Quantity Q>
|
||||
void print_header(kalman::estimation<Q> initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>5} | {:>8} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate",
|
||||
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");
|
||||
}
|
||||
|
||||
template<Quantity Q, Dimensionless K>
|
||||
void print(auto iteration, K gain, Q measured, kalman::estimation<Q> current, kalman::estimation<Q> next)
|
||||
{
|
||||
std::cout << 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, current,
|
||||
next);
|
||||
}
|
||||
|
||||
|
@@ -55,15 +55,15 @@ using namespace units;
|
||||
template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate",
|
||||
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");
|
||||
}
|
||||
|
||||
template<QuantityPoint QP, Dimensionless K>
|
||||
void print(auto iteration, K gain, QP measured, kalman::estimation<QP> current, kalman::estimation<QP> next)
|
||||
{
|
||||
std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain,
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain,
|
||||
measured.relative(), current, next);
|
||||
}
|
||||
|
||||
|
@@ -55,15 +55,15 @@ using namespace units;
|
||||
template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>18} | {:>18}\n", "N", "Gain", "Measured", "Curr. Estimate",
|
||||
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");
|
||||
}
|
||||
|
||||
template<QuantityPoint QP, Dimensionless K>
|
||||
void print(auto iteration, K gain, QP measured, kalman::estimation<QP> current, kalman::estimation<QP> next)
|
||||
{
|
||||
std::cout << STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain,
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:7%.4Q} | {:10%.3Q %q} | {:>18.3} | {:>18.3}\n", iteration, gain,
|
||||
measured.relative(), current, next);
|
||||
}
|
||||
|
||||
|
@@ -55,15 +55,15 @@ using namespace units;
|
||||
template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> initial)
|
||||
{
|
||||
std::cout << STD_FMT::format("Initial: {}\n", initial);
|
||||
std::cout << STD_FMT::format("{:>2} | {:>7} | {:>10} | {:>16} | {:>16}\n", "N", "Gain", "Measured", "Curr. Estimate",
|
||||
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");
|
||||
}
|
||||
|
||||
template<QuantityPoint QP, Dimensionless K>
|
||||
void print(auto iteration, K gain, QP measured, kalman::estimation<QP> current, kalman::estimation<QP> next)
|
||||
{
|
||||
std::cout << STD_FMT::format("{:2} | {:7%.3Q} | {:10%.3Q %q} | {:>16.2} | {:>16.2}\n", iteration, gain,
|
||||
std::cout << UNITS_STD_FMT::format("{:2} | {:7%.3Q} | {:10%.3Q %q} | {:>16.2} | {:>16.2}\n", iteration, gain,
|
||||
measured.relative(), current, next);
|
||||
}
|
||||
|
||||
|
@@ -108,9 +108,9 @@ int main()
|
||||
const Time auto fill_time_left = (height / fill_level - 1) * fill_time;
|
||||
|
||||
std::cout << "mp-units box example...\n";
|
||||
std::cout << STD_FMT::format("fill height at {} = {} ({} full)\n", fill_time, fill_level, fill_percent);
|
||||
std::cout << STD_FMT::format("spare_capacity at {} = {}\n", fill_time, spare_capacity);
|
||||
std::cout << STD_FMT::format("input flow rate after {} = {}\n", fill_time, input_flow_rate);
|
||||
std::cout << STD_FMT::format("float rise rate = {}\n", float_rise_rate);
|
||||
std::cout << STD_FMT::format("box full E.T.A. at current flow rate = {}\n", fill_time_left);
|
||||
std::cout << UNITS_STD_FMT::format("fill height at {} = {} ({} full)\n", fill_time, fill_level, fill_percent);
|
||||
std::cout << UNITS_STD_FMT::format("spare_capacity at {} = {}\n", fill_time, spare_capacity);
|
||||
std::cout << UNITS_STD_FMT::format("input flow rate after {} = {}\n", fill_time, input_flow_rate);
|
||||
std::cout << UNITS_STD_FMT::format("float rise rate = {}\n", float_rise_rate);
|
||||
std::cout << UNITS_STD_FMT::format("box full E.T.A. at current flow rate = {}\n", fill_time_left);
|
||||
}
|
||||
|
@@ -114,7 +114,7 @@ void calcs_comparison()
|
||||
const length<femtometre, float> L1A = 2._q_fm;
|
||||
const length<femtometre, float> L2A = 3._q_fm;
|
||||
const length<femtometre, float> LrA = L1A + L2A;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA);
|
||||
|
||||
std::cout << "The single unit method must convert large\n"
|
||||
"or small values in other units to the base unit.\n"
|
||||
@@ -123,17 +123,17 @@ void calcs_comparison()
|
||||
const length<metre, float> L1B = L1A;
|
||||
const length<metre, float> L2B = L2A;
|
||||
const length<metre, float> LrB = L1B + L2B;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB);
|
||||
|
||||
std::cout << "In multiplication and division:\n\n";
|
||||
|
||||
const area<square_femtometre, float> ArA = L1A * L2A;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA);
|
||||
|
||||
std::cout << "similar problems arise\n\n";
|
||||
|
||||
const area<square_metre, float> ArB = L1B * L2B;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -57,7 +57,7 @@ struct Ship {
|
||||
template<class... Args, units::Quantity Q>
|
||||
auto fmt_line(const Q a)
|
||||
{
|
||||
return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast<Args>(a)) + ...);
|
||||
return UNITS_STD_FMT::format("{:22}", a) + (UNITS_STD_FMT::format(",{:20}", units::quantity_cast<Args>(a)) + ...);
|
||||
}
|
||||
|
||||
// Print the ship details in the units as defined in the Ship struct, in other si::imperial units, and in SI
|
||||
@@ -65,28 +65,28 @@ 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 << STD_FMT::format("{}\n", description);
|
||||
std::cout << STD_FMT::format("{:20} : {}\n", "length",
|
||||
std::cout << UNITS_STD_FMT::format("{}\n", description);
|
||||
std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length))
|
||||
<< 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))
|
||||
<< STD_FMT::format("{:20} : {}\n", "beam",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "beam",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.beam))
|
||||
<< STD_FMT::format("{:20} : {}\n", "mass",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "mass",
|
||||
fmt_line<si::fps::mass<si::fps::long_ton>, si::mass<si::tonne>>(ship.mass))
|
||||
<< STD_FMT::format(
|
||||
<< UNITS_STD_FMT::format(
|
||||
"{:20} : {}\n", "speed",
|
||||
fmt_line<si::speed<si::international::knot>, si::speed<si::kilometre_per_hour>>(ship.speed))
|
||||
<< STD_FMT::format("{:20} : {}\n", "power",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "power",
|
||||
fmt_line<si::fps::power<si::fps::horse_power>, si::power<si::kilowatt>>(ship.power))
|
||||
<< STD_FMT::format("{:20} : {}\n", "main guns",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "main guns",
|
||||
fmt_line<si::fps::length<si::fps::inch>, si::length<si::millimetre>>(ship.mainGuns))
|
||||
<< STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
fmt_line<si::fps::mass<si::fps::long_ton>, si::mass<si::kilogram>>(ship.shellMass))
|
||||
<< STD_FMT::format(
|
||||
<< UNITS_STD_FMT::format(
|
||||
"{:20} : {}\n", "fire shells at",
|
||||
fmt_line<si::fps::speed<si::fps::mile_per_hour>, si::speed<si::kilometre_per_hour>>(ship.shellSpeed))
|
||||
<< STD_FMT::format("{:20} : {}\n", "volume underwater",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater",
|
||||
fmt_line<si::volume<si::cubic_metre>, si::volume<si::litre>>(ship.mass / waterDensity));
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,7 @@ 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 << 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, ratio,
|
||||
units::quantity_cast<units::degree>(asin(1 / ratio)));
|
||||
}
|
||||
std::cout << "\n";
|
||||
@@ -102,8 +102,8 @@ void print(const R& conditions)
|
||||
for (const auto& c : conditions) {
|
||||
std::cout << "- " << c.first << "\n";
|
||||
const auto& w = c.second;
|
||||
std::cout << " * Cloud base: " << STD_FMT::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << STD_FMT::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << " * Cloud base: " << UNITS_STD_FMT::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << UNITS_STD_FMT::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ void print(const R& waypoints)
|
||||
std::cout << "Waypoints:\n";
|
||||
std::cout << "==========\n";
|
||||
for (const auto& w : waypoints)
|
||||
std::cout << STD_FMT::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << UNITS_STD_FMT::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -126,12 +126,12 @@ void print(const task& t)
|
||||
|
||||
std::cout << "- Start: " << t.get_start().name << "\n";
|
||||
std::cout << "- Finish: " << t.get_finish().name << "\n";
|
||||
std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
std::cout << "- Length: " << UNITS_STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
|
||||
std::cout << "- Legs: "
|
||||
<< "\n";
|
||||
for (const auto& l : t.get_legs())
|
||||
std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << UNITS_STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void print(const safety& s)
|
||||
{
|
||||
std::cout << "Safety:\n";
|
||||
std::cout << "=======\n";
|
||||
std::cout << "- Min AGL separation: " << STD_FMT::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "- Min AGL separation: " << UNITS_STD_FMT::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ void print(const aircraft_tow& tow)
|
||||
std::cout << "Tow:\n";
|
||||
std::cout << "====\n";
|
||||
std::cout << "- Type: aircraft\n";
|
||||
std::cout << "- Height: " << STD_FMT::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << STD_FMT::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "- Height: " << UNITS_STD_FMT::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << UNITS_STD_FMT::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ void example()
|
||||
for (const auto& c : weather_conditions) {
|
||||
std::string txt = "Scenario: Glider = " + g.name + ", Weather = " + c.first;
|
||||
std::cout << txt << "\n";
|
||||
std::cout << STD_FMT::format("{0:=^{1}}\n\n", "", txt.size());
|
||||
std::cout << UNITS_STD_FMT::format("{0:=^{1}}\n\n", "", txt.size());
|
||||
|
||||
estimate(start_time, g, c.second, t, sfty, tow);
|
||||
|
||||
|
@@ -36,7 +36,7 @@ std::ostream& operator<<(std::ostream& os, const vector<ET, OT>& v)
|
||||
{
|
||||
os << "|";
|
||||
for (auto i = 0U; i < v.size(); ++i) {
|
||||
os << STD_FMT::format(" {:>9}", v(i));
|
||||
os << UNITS_STD_FMT::format(" {:>9}", v(i));
|
||||
}
|
||||
os << " |";
|
||||
return os;
|
||||
@@ -48,7 +48,7 @@ std::ostream& operator<<(std::ostream& os, const matrix<ET, OT>& v)
|
||||
for (auto i = 0U; i < v.rows(); ++i) {
|
||||
os << "|";
|
||||
for (auto j = 0U; j < v.columns(); ++j) {
|
||||
os << STD_FMT::format(" {:>9}", v(i, j));
|
||||
os << UNITS_STD_FMT::format(" {:>9}", v(i, j));
|
||||
}
|
||||
os << (i != v.rows() - 1U ? " |\n" : " |");
|
||||
}
|
||||
|
@@ -104,9 +104,9 @@ int main()
|
||||
const Time auto fill_time_left = (height / fill_level - 1) * fill_time;
|
||||
|
||||
std::cout << "mp-units box example...\n";
|
||||
std::cout << STD_FMT::format("fill height at {} = {} ({} full)\n", fill_time, fill_level, fill_percent);
|
||||
std::cout << STD_FMT::format("spare_capacity at {} = {}\n", fill_time, spare_capacity);
|
||||
std::cout << STD_FMT::format("input flow rate after {} = {}\n", fill_time, input_flow_rate);
|
||||
std::cout << STD_FMT::format("float rise rate = {}\n", float_rise_rate);
|
||||
std::cout << STD_FMT::format("box full E.T.A. at current flow rate = {}\n", fill_time_left);
|
||||
std::cout << UNITS_STD_FMT::format("fill height at {} = {} ({} full)\n", fill_time, fill_level, fill_percent);
|
||||
std::cout << UNITS_STD_FMT::format("spare_capacity at {} = {}\n", fill_time, spare_capacity);
|
||||
std::cout << UNITS_STD_FMT::format("input flow rate after {} = {}\n", fill_time, input_flow_rate);
|
||||
std::cout << UNITS_STD_FMT::format("float rise rate = {}\n", float_rise_rate);
|
||||
std::cout << UNITS_STD_FMT::format("box full E.T.A. at current flow rate = {}\n", fill_time_left);
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ void calcs_comparison()
|
||||
const length<femtometre, float> L1A = 2.f * fm;
|
||||
const length<femtometre, float> L2A = 3.f * fm;
|
||||
const length<femtometre, float> LrA = L1A + L2A;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, LrA);
|
||||
|
||||
std::cout << "The single unit method must convert large\n"
|
||||
"or small values in other units to the base unit.\n"
|
||||
@@ -132,17 +132,17 @@ void calcs_comparison()
|
||||
const length<metre, float> L1B = L1A;
|
||||
const length<metre, float> L2B = L2A;
|
||||
const length<metre, float> LrB = L1B + L2B;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n + {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, LrB);
|
||||
|
||||
std::cout << "In multiplication and division:\n\n";
|
||||
|
||||
const area<square_femtometre, float> ArA = L1A * L2A;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1A, L2A, ArA);
|
||||
|
||||
std::cout << "similar problems arise\n\n";
|
||||
|
||||
const area<square_metre, float> ArB = L1B * L2B;
|
||||
std::cout << STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB);
|
||||
std::cout << UNITS_STD_FMT::format("{:%.30Q %q}\n * {:%.30Q %q}\n = {:%.30Q %q}\n\n", L1B, L2B, ArB);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -60,7 +60,7 @@ struct Ship {
|
||||
template<class... Args, units::Quantity Q>
|
||||
auto fmt_line(const Q a)
|
||||
{
|
||||
return STD_FMT::format("{:22}", a) + (STD_FMT::format(",{:20}", units::quantity_cast<Args>(a)) + ...);
|
||||
return UNITS_STD_FMT::format("{:22}", a) + (UNITS_STD_FMT::format(",{:20}", units::quantity_cast<Args>(a)) + ...);
|
||||
}
|
||||
|
||||
// Print the ship details in the units as defined in the Ship struct, in other si::imperial units, and in SI
|
||||
@@ -68,28 +68,28 @@ 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 << STD_FMT::format("{}\n", description);
|
||||
std::cout << STD_FMT::format("{:20} : {}\n", "length",
|
||||
std::cout << UNITS_STD_FMT::format("{}\n", description);
|
||||
std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.length))
|
||||
<< 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))
|
||||
<< STD_FMT::format("{:20} : {}\n", "beam",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "beam",
|
||||
fmt_line<si::fps::length<si::fps::yard>, si::length<si::metre>>(ship.beam))
|
||||
<< STD_FMT::format("{:20} : {}\n", "mass",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "mass",
|
||||
fmt_line<si::fps::mass<si::fps::long_ton>, si::mass<si::tonne>>(ship.mass))
|
||||
<< STD_FMT::format(
|
||||
<< UNITS_STD_FMT::format(
|
||||
"{:20} : {}\n", "speed",
|
||||
fmt_line<si::speed<si::international::knot>, si::speed<si::kilometre_per_hour>>(ship.speed))
|
||||
<< STD_FMT::format("{:20} : {}\n", "power",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "power",
|
||||
fmt_line<si::fps::power<si::fps::horse_power>, si::power<si::kilowatt>>(ship.power))
|
||||
<< STD_FMT::format("{:20} : {}\n", "main guns",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "main guns",
|
||||
fmt_line<si::fps::length<si::fps::inch>, si::length<si::millimetre>>(ship.mainGuns))
|
||||
<< STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
fmt_line<si::fps::mass<si::fps::long_ton>, si::mass<si::kilogram>>(ship.shellMass))
|
||||
<< STD_FMT::format(
|
||||
<< UNITS_STD_FMT::format(
|
||||
"{:20} : {}\n", "fire shells at",
|
||||
fmt_line<si::fps::speed<si::fps::mile_per_hour>, si::speed<si::kilometre_per_hour>>(ship.shellSpeed))
|
||||
<< STD_FMT::format("{:20} : {}\n", "volume underwater",
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater",
|
||||
fmt_line<si::volume<si::cubic_metre>, si::volume<si::litre>>(ship.mass / waterDensity));
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,7 @@ 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 << 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, ratio,
|
||||
units::quantity_cast<units::degree>(asin(1 / ratio)));
|
||||
}
|
||||
std::cout << "\n";
|
||||
@@ -102,8 +102,8 @@ void print(const R& conditions)
|
||||
for (const auto& c : conditions) {
|
||||
std::cout << "- " << c.first << "\n";
|
||||
const auto& w = c.second;
|
||||
std::cout << " * Cloud base: " << STD_FMT::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << STD_FMT::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << " * Cloud base: " << UNITS_STD_FMT::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << UNITS_STD_FMT::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ void print(const R& waypoints)
|
||||
std::cout << "Waypoints:\n";
|
||||
std::cout << "==========\n";
|
||||
for (const auto& w : waypoints)
|
||||
std::cout << STD_FMT::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << UNITS_STD_FMT::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -126,12 +126,12 @@ void print(const task& t)
|
||||
|
||||
std::cout << "- Start: " << t.get_start().name << "\n";
|
||||
std::cout << "- Finish: " << t.get_finish().name << "\n";
|
||||
std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
std::cout << "- Length: " << UNITS_STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
|
||||
std::cout << "- Legs: "
|
||||
<< "\n";
|
||||
for (const auto& l : t.get_legs())
|
||||
std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << UNITS_STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void print(const safety& s)
|
||||
{
|
||||
std::cout << "Safety:\n";
|
||||
std::cout << "=======\n";
|
||||
std::cout << "- Min AGL separation: " << STD_FMT::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "- Min AGL separation: " << UNITS_STD_FMT::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ void print(const aircraft_tow& tow)
|
||||
std::cout << "Tow:\n";
|
||||
std::cout << "====\n";
|
||||
std::cout << "- Type: aircraft\n";
|
||||
std::cout << "- Height: " << STD_FMT::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << STD_FMT::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "- Height: " << UNITS_STD_FMT::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << UNITS_STD_FMT::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ void example()
|
||||
for (const auto& c : weather_conditions) {
|
||||
std::string txt = "Scenario: Glider = " + g.name + ", Weather = " + c.first;
|
||||
std::cout << txt << "\n";
|
||||
std::cout << STD_FMT::format("{0:=^{1}}\n\n", "", txt.size());
|
||||
std::cout << UNITS_STD_FMT::format("{0:=^{1}}\n\n", "", txt.size());
|
||||
|
||||
estimate(start_time, g, c.second, t, sfty, tow);
|
||||
|
||||
|
@@ -36,7 +36,7 @@ std::ostream& operator<<(std::ostream& os, const vector<ET, OT>& v)
|
||||
{
|
||||
os << "|";
|
||||
for (auto i = 0U; i < v.size(); ++i) {
|
||||
os << STD_FMT::format(" {:>9}", v(i));
|
||||
os << UNITS_STD_FMT::format(" {:>9}", v(i));
|
||||
}
|
||||
os << " |";
|
||||
return os;
|
||||
@@ -48,7 +48,7 @@ std::ostream& operator<<(std::ostream& os, const matrix<ET, OT>& v)
|
||||
for (auto i = 0U; i < v.rows(); ++i) {
|
||||
os << "|";
|
||||
for (auto j = 0U; j < v.columns(); ++j) {
|
||||
os << STD_FMT::format(" {:>9}", v(i, j));
|
||||
os << UNITS_STD_FMT::format(" {:>9}", v(i, j));
|
||||
}
|
||||
os << (i != v.rows() - 1U ? " |\n" : " |");
|
||||
}
|
||||
|
@@ -29,12 +29,12 @@ int main()
|
||||
using namespace units::isq::si::si2019;
|
||||
|
||||
std::cout << "The seven defining constants of the SI and the seven corresponding units they define:\n";
|
||||
std::cout << STD_FMT::format("- hyperfine transition frequency of Cs: {:%.0Q %q}\n",
|
||||
std::cout << UNITS_STD_FMT::format("- hyperfine transition frequency of Cs: {:%.0Q %q}\n",
|
||||
hyperfine_structure_transition_frequency<>);
|
||||
std::cout << STD_FMT::format("- speed of light in vacuum: {:%.0Q %q}\n", speed_of_light<>);
|
||||
std::cout << STD_FMT::format("- Planck constant: {}\n", planck_constant<>);
|
||||
std::cout << STD_FMT::format("- elementary charge: {}\n", elementary_charge<>);
|
||||
std::cout << STD_FMT::format("- Boltzmann constant: {}\n", boltzmann_constant<>);
|
||||
std::cout << STD_FMT::format("- Avogadro constant: {}\n", avogadro_constant<>);
|
||||
std::cout << STD_FMT::format("- luminous efficacy: {}\n", luminous_efficacy<>);
|
||||
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<>);
|
||||
std::cout << UNITS_STD_FMT::format("- Boltzmann constant: {}\n", boltzmann_constant<>);
|
||||
std::cout << UNITS_STD_FMT::format("- Avogadro constant: {}\n", avogadro_constant<>);
|
||||
std::cout << UNITS_STD_FMT::format("- luminous efficacy: {}\n", luminous_efficacy<>);
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public:
|
||||
constexpr fill_t& operator=(std::basic_string_view<Char> str)
|
||||
{
|
||||
auto size = str.size();
|
||||
if (size > max_size) FMT_THROW(STD_FMT::format_error("invalid fill"));
|
||||
if (size > max_size) UNITS_THROW(UNITS_STD_FMT::format_error("invalid fill"));
|
||||
for (size_t i = 0; i < size; ++i) data_[i] = str[i];
|
||||
size_ = static_cast<unsigned char>(size);
|
||||
return *this;
|
||||
@@ -98,11 +98,11 @@ struct width_checker {
|
||||
{
|
||||
if constexpr (is_integer<T>) {
|
||||
if constexpr (std::numeric_limits<T>::is_signed) {
|
||||
if (value < 0) FMT_THROW(STD_FMT::format_error("negative width"));
|
||||
if (value < 0) UNITS_THROW(UNITS_STD_FMT::format_error("negative width"));
|
||||
}
|
||||
return static_cast<unsigned long long>(value);
|
||||
} else {
|
||||
FMT_THROW(STD_FMT::format_error("width is not integer"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("width is not integer"));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -113,11 +113,11 @@ struct precision_checker {
|
||||
{
|
||||
if constexpr (is_integer<T>) {
|
||||
if constexpr (std::numeric_limits<T>::is_signed) {
|
||||
if (value < 0) FMT_THROW(STD_FMT::format_error("negative precision"));
|
||||
if (value < 0) UNITS_THROW(UNITS_STD_FMT::format_error("negative precision"));
|
||||
}
|
||||
return static_cast<unsigned long long>(value);
|
||||
} else {
|
||||
FMT_THROW(STD_FMT::format_error("precision is not integer"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("precision is not integer"));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -147,31 +147,31 @@ struct dynamic_format_specs : basic_format_specs<Char> {
|
||||
[[nodiscard]] constexpr int verify_dynamic_arg_index_in_range(size_t idx)
|
||||
{
|
||||
if (idx > static_cast<size_t>(std::numeric_limits<int>::max())) {
|
||||
FMT_THROW(STD_FMT::format_error("Dynamic width or precision index too large."));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("Dynamic width or precision index too large."));
|
||||
}
|
||||
return static_cast<int>(idx);
|
||||
}
|
||||
|
||||
template<typename CharT>
|
||||
[[nodiscard]] constexpr int on_dynamic_arg(size_t arg_id, STD_FMT::basic_format_parse_context<CharT>& context)
|
||||
[[nodiscard]] constexpr int on_dynamic_arg(size_t arg_id, UNITS_STD_FMT::basic_format_parse_context<CharT>& context)
|
||||
{
|
||||
context.check_arg_id(FMT_TO_ARG_ID(arg_id));
|
||||
context.check_arg_id(UNITS_FMT_TO_ARG_ID(arg_id));
|
||||
return verify_dynamic_arg_index_in_range(arg_id);
|
||||
}
|
||||
|
||||
template<typename CharT>
|
||||
[[nodiscard]] constexpr int on_dynamic_arg(auto_id, STD_FMT::basic_format_parse_context<CharT>& context)
|
||||
[[nodiscard]] constexpr int on_dynamic_arg(auto_id, UNITS_STD_FMT::basic_format_parse_context<CharT>& context)
|
||||
{
|
||||
return verify_dynamic_arg_index_in_range(FMT_FROM_ARG_ID(context.next_arg_id()));
|
||||
return verify_dynamic_arg_index_in_range(UNITS_FMT_FROM_ARG_ID(context.next_arg_id()));
|
||||
}
|
||||
|
||||
template<class Handler, typename FormatContext>
|
||||
[[nodiscard]] constexpr int get_dynamic_spec(int index, FormatContext& ctx)
|
||||
{
|
||||
const unsigned long long value =
|
||||
STD_FMT::visit_format_arg(Handler{}, ctx.arg(FMT_TO_ARG_ID(static_cast<size_t>(index))));
|
||||
UNITS_STD_FMT::visit_format_arg(Handler{}, ctx.arg(UNITS_FMT_TO_ARG_ID(static_cast<size_t>(index))));
|
||||
if (value > static_cast<unsigned long long>(std::numeric_limits<int>::max())) {
|
||||
FMT_THROW(STD_FMT::format_error("number is too big"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("number is too big"));
|
||||
}
|
||||
return static_cast<int>(value);
|
||||
}
|
||||
@@ -195,7 +195,7 @@ template<std::input_iterator It, std::sentinel_for<It> S>
|
||||
++begin;
|
||||
} while (begin != end && '0' <= *begin && *begin <= '9');
|
||||
|
||||
if (value > max_int) FMT_THROW(STD_FMT::format_error("Number is too big"));
|
||||
if (value > max_int) UNITS_THROW(UNITS_STD_FMT::format_error("Number is too big"));
|
||||
|
||||
return begin;
|
||||
}
|
||||
@@ -222,12 +222,12 @@ template<std::input_iterator It, std::sentinel_for<It> S, typename IDHandler>
|
||||
else
|
||||
++begin;
|
||||
if (begin == end || (*begin != '}' && *begin != ':'))
|
||||
FMT_THROW(STD_FMT::format_error("invalid format string"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("invalid format string"));
|
||||
else
|
||||
handler(index);
|
||||
return begin;
|
||||
}
|
||||
FMT_THROW(STD_FMT::format_error("invalid format string"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("invalid format string"));
|
||||
}
|
||||
|
||||
template<std::input_iterator It, std::sentinel_for<It> S, typename IDHandler>
|
||||
@@ -278,11 +278,11 @@ template<std::input_iterator It, std::sentinel_for<It> S, typename Handler>
|
||||
if (width != -1)
|
||||
handler.on_width(width);
|
||||
else
|
||||
FMT_THROW(STD_FMT::format_error("number is too big"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("number is too big"));
|
||||
} else if (*begin == '{') {
|
||||
++begin;
|
||||
if (begin != end) begin = parse_arg_id(begin, end, width_adapter{handler});
|
||||
if (begin == end || *begin != '}') FMT_THROW(STD_FMT::format_error("invalid format string"));
|
||||
if (begin == end || *begin != '}') UNITS_THROW(UNITS_STD_FMT::format_error("invalid format string"));
|
||||
++begin;
|
||||
}
|
||||
return begin;
|
||||
@@ -305,13 +305,13 @@ template<std::input_iterator It, std::sentinel_for<It> S, typename Handler>
|
||||
if (precision != -1)
|
||||
handler.on_precision(precision);
|
||||
else
|
||||
FMT_THROW(STD_FMT::format_error("number is too big"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("number is too big"));
|
||||
} else if (c == '{') {
|
||||
++begin;
|
||||
if (begin != end) begin = parse_arg_id(begin, end, precision_adapter{handler});
|
||||
if (begin == end || *begin++ != '}') FMT_THROW(STD_FMT::format_error("invalid format string"));
|
||||
if (begin == end || *begin++ != '}') UNITS_THROW(UNITS_STD_FMT::format_error("invalid format string"));
|
||||
} else {
|
||||
FMT_THROW(STD_FMT::format_error("missing precision specifier"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("missing precision specifier"));
|
||||
}
|
||||
return begin;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ template<std::input_iterator It, std::sentinel_for<It> S, typename Handler>
|
||||
if (align != fmt_align::none) {
|
||||
if (p != begin) {
|
||||
auto c = *begin;
|
||||
if (c == '{') FMT_THROW(STD_FMT::format_error("invalid fill character '{'"));
|
||||
if (c == '{') UNITS_THROW(UNITS_STD_FMT::format_error("invalid fill character '{'"));
|
||||
handler.on_fill(std::basic_string_view<std::iter_value_t<It>>(&*begin, static_cast<size_t>(p - begin)));
|
||||
begin = p + 1;
|
||||
} else
|
||||
|
@@ -41,10 +41,19 @@ UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
||||
#include <fmt/format.h>
|
||||
UNITS_DIAGNOSTIC_POP
|
||||
|
||||
#define STD_FMT fmt
|
||||
#define FMT_LOCALE(loc) (loc).template get<std::locale>()
|
||||
#define FMT_TO_ARG_ID(arg) static_cast<int>(arg)
|
||||
#define FMT_FROM_ARG_ID(arg) static_cast<size_t>(arg)
|
||||
#define UNITS_STD_FMT fmt
|
||||
#define UNITS_FMT_LOCALE(loc) (loc).template get<std::locale>()
|
||||
#define UNITS_FMT_TO_ARG_ID(arg) static_cast<int>(arg)
|
||||
#define UNITS_FMT_FROM_ARG_ID(arg) static_cast<size_t>(arg)
|
||||
|
||||
// just reuse FMT_THROW - we're anyway only throwing from within string formatting code
|
||||
#if FMT_EXCEPTIONS && (FMT_MSC_VERSION || defined(__NVCC__))
|
||||
// work around FMT_THROW being defined without a fully qualified namespace
|
||||
#define UNITS_THROW(x) ::fmt::detail::do_throw(x)
|
||||
#else
|
||||
#define UNITS_THROW(x) FMT_THROW(x)
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
@@ -54,10 +63,10 @@ UNITS_DIAGNOSTIC_POP
|
||||
|
||||
#include <format>
|
||||
|
||||
#define STD_FMT std
|
||||
#define FMT_LOCALE(loc) loc
|
||||
#define FMT_TO_ARG_ID(arg) arg
|
||||
#define FMT_FROM_ARG_ID(arg) arg
|
||||
#define FMT_THROW(arg) throw arg
|
||||
#define UNITS_STD_FMT std
|
||||
#define UNITS_FMT_LOCALE(loc) loc
|
||||
#define UNITS_FMT_TO_ARG_ID(arg) arg
|
||||
#define UNITS_FMT_FROM_ARG_ID(arg) arg
|
||||
#define UNITS_THROW(arg) throw arg
|
||||
|
||||
#endif
|
||||
|
@@ -54,24 +54,24 @@
|
||||
// - Add the new symbol in the `units_types` variable in the `parse_units_format` function
|
||||
// - Add a new case in the `if` following the format_error in `parse_units_format` function;
|
||||
// this should invoke `handler.on_[...]`
|
||||
// - Edit `STD_FMT::formatter`:
|
||||
// - Edit `UNITS_STD_FMT::formatter`:
|
||||
// - Add a new field for the flag/specs
|
||||
// - Add to the `STD_FMT::formatter::spec_handler` a `on_[...]` function that set the flag/specs if needed
|
||||
// - Add to the `UNITS_STD_FMT::formatter::spec_handler` a `on_[...]` function that set the flag/specs if needed
|
||||
// - Edit `quantity_formatter`:
|
||||
// - Add a new field for the flag/specs
|
||||
// - write a `on_[...]` function that writes to the `out` iterator the correct output
|
||||
//
|
||||
// If you want to add a new `units-rep-type`:
|
||||
// - Add the new symbol in the `valid_rep_types` variable (which is in the
|
||||
// STD_FMT::formatter::spec_handler::on_type member function)
|
||||
// UNITS_STD_FMT::formatter::spec_handler::on_type member function)
|
||||
// NB: currently this function forward the modifier to the value that must be formatted;
|
||||
// if the symbol has no meaning for STD_FMT::formatter<Rep>, this behavior should be disabled manually
|
||||
// if the symbol has no meaning for UNITS_STD_FMT::formatter<Rep>, this behavior should be disabled manually
|
||||
// (as is done for '\0')
|
||||
// - Implement the effect of the new flag in `format_units_quantity_value`
|
||||
//
|
||||
// If you want to add a new `units-unit-modifier`:
|
||||
// - Add the new symbol in the `valid_modifiers` variable (which is in the
|
||||
// STD_FMT::formatter::spec_handler::on_unit_modifier member function)
|
||||
// UNITS_STD_FMT::formatter::spec_handler::on_unit_modifier member function)
|
||||
// - Implement the effect of the new flag in the `quantity_formatter::on_quantity_unit` member function
|
||||
|
||||
namespace units::detail {
|
||||
@@ -126,7 +126,7 @@ constexpr const It parse_units_rep(It begin, S end, Handler&& handler, bool trea
|
||||
if (treat_as_floating_point) {
|
||||
begin = parse_precision(begin, end, handler);
|
||||
} else
|
||||
FMT_THROW(STD_FMT::format_error("precision not allowed for integral quantity representation"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("precision not allowed for integral quantity representation"));
|
||||
if (begin == end) return begin;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ constexpr It parse_units_format(It begin, S end, Handler&& handler)
|
||||
}
|
||||
if (begin != ptr) handler.on_text(begin, ptr);
|
||||
begin = ++ptr; // consume '%'
|
||||
if (ptr == end) FMT_THROW(STD_FMT::format_error("invalid format"));
|
||||
if (ptr == end) UNITS_THROW(UNITS_STD_FMT::format_error("invalid format"));
|
||||
c = *ptr++;
|
||||
|
||||
switch (c) {
|
||||
@@ -177,7 +177,7 @@ constexpr It parse_units_format(It begin, S end, Handler&& handler)
|
||||
default:
|
||||
constexpr auto units_types = std::string_view{"Qq"};
|
||||
const auto new_end = std::find_first_of(begin, end, units_types.begin(), units_types.end());
|
||||
if (new_end == end) FMT_THROW(STD_FMT::format_error("invalid format"));
|
||||
if (new_end == end) UNITS_THROW(UNITS_STD_FMT::format_error("invalid format"));
|
||||
if (*new_end == 'Q') {
|
||||
handler.on_quantity_value(begin, new_end); // Edit `on_quantity_value` to add rep modifiers
|
||||
} else {
|
||||
@@ -199,43 +199,43 @@ template<typename CharT, typename Rep, typename OutputIt, typename Locale>
|
||||
std::basic_string<CharT> buffer;
|
||||
auto to_buffer = std::back_inserter(buffer);
|
||||
|
||||
STD_FMT::format_to(to_buffer, "{{:");
|
||||
UNITS_STD_FMT::format_to(to_buffer, "{{:");
|
||||
switch (rep_specs.sign) {
|
||||
case fmt_sign::none:
|
||||
break;
|
||||
case fmt_sign::plus:
|
||||
STD_FMT::format_to(to_buffer, "+");
|
||||
UNITS_STD_FMT::format_to(to_buffer, "+");
|
||||
break;
|
||||
case fmt_sign::minus:
|
||||
STD_FMT::format_to(to_buffer, "-");
|
||||
UNITS_STD_FMT::format_to(to_buffer, "-");
|
||||
break;
|
||||
case fmt_sign::space:
|
||||
STD_FMT::format_to(to_buffer, " ");
|
||||
UNITS_STD_FMT::format_to(to_buffer, " ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (rep_specs.alt) {
|
||||
STD_FMT::format_to(to_buffer, "#");
|
||||
UNITS_STD_FMT::format_to(to_buffer, "#");
|
||||
}
|
||||
auto type = rep_specs.type;
|
||||
if (auto precision = rep_specs.precision; precision >= 0) {
|
||||
STD_FMT::format_to(to_buffer, ".{}{}", precision, type == '\0' ? 'f' : type);
|
||||
UNITS_STD_FMT::format_to(to_buffer, ".{}{}", precision, type == '\0' ? 'f' : type);
|
||||
} else if constexpr (treat_as_floating_point<Rep>) {
|
||||
STD_FMT::format_to(to_buffer, "{}", type == '\0' ? 'g' : type);
|
||||
UNITS_STD_FMT::format_to(to_buffer, "{}", type == '\0' ? 'g' : type);
|
||||
} else {
|
||||
if (type != '\0') {
|
||||
STD_FMT::format_to(to_buffer, "{}", type);
|
||||
UNITS_STD_FMT::format_to(to_buffer, "{}", type);
|
||||
}
|
||||
}
|
||||
if (rep_specs.localized) {
|
||||
STD_FMT::format_to(to_buffer, "L");
|
||||
UNITS_STD_FMT::format_to(to_buffer, "L");
|
||||
}
|
||||
|
||||
STD_FMT::format_to(to_buffer, "}}");
|
||||
UNITS_STD_FMT::format_to(to_buffer, "}}");
|
||||
if (rep_specs.localized) {
|
||||
return STD_FMT::vformat_to(out, FMT_LOCALE(loc), buffer, STD_FMT::make_format_args(val));
|
||||
return UNITS_STD_FMT::vformat_to(out, UNITS_FMT_LOCALE(loc), buffer, UNITS_STD_FMT::make_format_args(val));
|
||||
}
|
||||
return STD_FMT::vformat_to(out, buffer, STD_FMT::make_format_args(val));
|
||||
return UNITS_STD_FMT::vformat_to(out, buffer, UNITS_STD_FMT::make_format_args(val));
|
||||
}
|
||||
|
||||
// Creates a global format string
|
||||
@@ -243,25 +243,25 @@ template<typename CharT, typename Rep, typename OutputIt, typename Locale>
|
||||
template<typename CharT, typename OutputIt>
|
||||
OutputIt format_global_buffer(OutputIt out, const quantity_global_format_specs<CharT>& specs)
|
||||
{
|
||||
STD_FMT::format_to(out, "{{:");
|
||||
UNITS_STD_FMT::format_to(out, "{{:");
|
||||
if (specs.fill.size() != 1 || specs.fill[0] != ' ') {
|
||||
STD_FMT::format_to(out, "{}", specs.fill.data());
|
||||
UNITS_STD_FMT::format_to(out, "{}", specs.fill.data());
|
||||
}
|
||||
switch (specs.align) {
|
||||
case fmt_align::left:
|
||||
STD_FMT::format_to(out, "<");
|
||||
UNITS_STD_FMT::format_to(out, "<");
|
||||
break;
|
||||
case fmt_align::right:
|
||||
STD_FMT::format_to(out, ">");
|
||||
UNITS_STD_FMT::format_to(out, ">");
|
||||
break;
|
||||
case fmt_align::center:
|
||||
STD_FMT::format_to(out, "^");
|
||||
UNITS_STD_FMT::format_to(out, "^");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (specs.width >= 1) STD_FMT::format_to(out, "{}", specs.width);
|
||||
return STD_FMT::format_to(out, "}}");
|
||||
if (specs.width >= 1) UNITS_STD_FMT::format_to(out, "{}", specs.width);
|
||||
return UNITS_STD_FMT::format_to(out, "}}");
|
||||
}
|
||||
|
||||
template<typename Dimension, typename Unit, typename Rep, typename Locale, typename CharT, typename OutputIt>
|
||||
@@ -293,9 +293,9 @@ struct quantity_formatter {
|
||||
{
|
||||
auto txt = unit_text<Dimension, Unit>();
|
||||
if (specs.unit.ascii_only) {
|
||||
STD_FMT::format_to(out, "{}", txt.ascii().c_str());
|
||||
UNITS_STD_FMT::format_to(out, "{}", txt.ascii().c_str());
|
||||
} else {
|
||||
STD_FMT::format_to(out, "{}", txt.standard().c_str());
|
||||
UNITS_STD_FMT::format_to(out, "{}", txt.standard().c_str());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -303,10 +303,10 @@ struct quantity_formatter {
|
||||
} // namespace units::detail
|
||||
|
||||
template<typename Dimension, typename Unit, typename Rep, typename CharT>
|
||||
struct STD_FMT::formatter<units::quantity<Dimension, Unit, Rep>, CharT> {
|
||||
struct UNITS_STD_FMT::formatter<units::quantity<Dimension, Unit, Rep>, CharT> {
|
||||
private:
|
||||
using quantity = units::quantity<Dimension, Unit, Rep>;
|
||||
using iterator = TYPENAME STD_FMT::basic_format_parse_context<CharT>::iterator;
|
||||
using iterator = TYPENAME UNITS_STD_FMT::basic_format_parse_context<CharT>::iterator;
|
||||
|
||||
bool quantity_value = false;
|
||||
bool quantity_unit = false;
|
||||
@@ -315,7 +315,7 @@ private:
|
||||
|
||||
struct spec_handler {
|
||||
formatter& f;
|
||||
STD_FMT::basic_format_parse_context<CharT>& context;
|
||||
UNITS_STD_FMT::basic_format_parse_context<CharT>& context;
|
||||
|
||||
constexpr void on_fill(std::basic_string_view<CharT> fill) { f.specs.global.fill = fill; }
|
||||
constexpr void on_align(units::detail::fmt_align align) { f.specs.global.align = align; }
|
||||
@@ -331,7 +331,7 @@ private:
|
||||
if (valid_rep_types.find(type) != std::string_view::npos) {
|
||||
f.specs.rep.type = type;
|
||||
} else {
|
||||
FMT_THROW(STD_FMT::format_error("invalid quantity type specifier"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("invalid quantity type specifier"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ private:
|
||||
if (valid_modifiers.find(mod) != std::string_view::npos) {
|
||||
f.specs.unit.ascii_only = true;
|
||||
} else {
|
||||
FMT_THROW(STD_FMT::format_error("invalid unit modifier specified"));
|
||||
UNITS_THROW(UNITS_STD_FMT::format_error("invalid unit modifier specified"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
[[nodiscard]] constexpr std::pair<iterator, iterator> do_parse(STD_FMT::basic_format_parse_context<CharT>& ctx)
|
||||
[[nodiscard]] constexpr std::pair<iterator, iterator> do_parse(UNITS_STD_FMT::basic_format_parse_context<CharT>& ctx)
|
||||
{
|
||||
auto begin = ctx.begin();
|
||||
auto end = ctx.end();
|
||||
@@ -416,7 +416,7 @@ private:
|
||||
constexpr auto symbol = units::detail::unit_text<Dimension, Unit>();
|
||||
if constexpr (symbol.standard().size() > 0) {
|
||||
*out++ = CharT(' ');
|
||||
STD_FMT::format_to(out, "{}", symbol.standard().c_str());
|
||||
UNITS_STD_FMT::format_to(out, "{}", symbol.standard().c_str());
|
||||
}
|
||||
} else {
|
||||
// user provided format
|
||||
@@ -427,7 +427,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
[[nodiscard]] constexpr auto parse(STD_FMT::basic_format_parse_context<CharT>& ctx)
|
||||
[[nodiscard]] constexpr auto parse(UNITS_STD_FMT::basic_format_parse_context<CharT>& ctx)
|
||||
{
|
||||
auto range = do_parse(ctx);
|
||||
if (range.first != range.second)
|
||||
@@ -464,8 +464,9 @@ public:
|
||||
units::detail::format_global_buffer<CharT>(std::back_inserter(global_format_buffer), specs.global);
|
||||
|
||||
// Format the `quantity buffer` using specs from `global_format_buffer`
|
||||
// In the example, equivalent to STD_FMT::format("{:*^10}", "1.2_m")
|
||||
return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(quantity_buffer));
|
||||
// In the example, equivalent to UNITS_STD_FMT::format("{:*^10}", "1.2_m")
|
||||
return UNITS_STD_FMT::vformat_to(ctx.out(), global_format_buffer,
|
||||
UNITS_STD_FMT::make_format_args(quantity_buffer));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -42,7 +42,7 @@ struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase {
|
||||
return abs(x - y) <= std::numeric_limits<typename T::rep>::epsilon() * maxXYOne;
|
||||
}
|
||||
|
||||
std::string describe() const override { return "almost equals: " + STD_FMT::format("{}", target_); }
|
||||
std::string describe() const override { return "almost equals: " + UNITS_STD_FMT::format("{}", target_); }
|
||||
|
||||
private:
|
||||
const T& target_;
|
||||
|
@@ -50,9 +50,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "60 W"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("floating-point representation")
|
||||
@@ -62,9 +62,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "1023.5 Pa"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "125 µs"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("quantity with a predefined unit + prefix")
|
||||
@@ -89,9 +89,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "123 Mm"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("in terms of derived units")
|
||||
@@ -101,9 +101,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "60 cJ"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 l"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("quantity with a prefixed alias unit")
|
||||
@@ -126,9 +126,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 ml"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("quantity with a derived unit")
|
||||
@@ -142,9 +142,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "10 m/s²"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("volume")
|
||||
@@ -154,9 +154,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 m³"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("surface tension")
|
||||
@@ -166,9 +166,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "10 N/m"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,9 +181,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "10 km/h"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("surface tension")
|
||||
@@ -195,9 +195,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "123 N/cm"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,9 +211,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 cJ"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("unit::ratio for a dimension without a special symbol")
|
||||
@@ -223,9 +223,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 × 10⁻¹⁰ m³"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den == 1")
|
||||
@@ -235,9 +235,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 [6 × 10¹] Hz"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("unit::ratio::num == 1 && unit::ratio::den != 1")
|
||||
@@ -247,9 +247,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "10 [1/6 × 10⁻¹] W"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den != 1")
|
||||
@@ -260,9 +260,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
// TODO(chogg): Reinstate after format/Magnitude design.
|
||||
// SECTION("iostream") { CHECK(os.str() == "30 [1/6 × 10²] W"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,9 +275,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == "2 "); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == "2 "); }
|
||||
}
|
||||
|
||||
SECTION("one with ratio.exp != 0")
|
||||
@@ -287,9 +287,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 × 10³"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == "2 × 10³"); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == "2 × 10³"); }
|
||||
}
|
||||
|
||||
SECTION("percents")
|
||||
@@ -303,9 +303,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "15 %"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,9 +320,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 m⋅kg⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("CGS base units")
|
||||
@@ -332,9 +332,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 cm⋅g⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,9 +345,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 × 10³ m⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den == 1")
|
||||
@@ -357,9 +357,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 [6 × 10¹] kg/s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("unit::ratio::num == 1 && unit::ratio::den != 1")
|
||||
@@ -369,9 +369,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "10 [1/6 × 10⁻¹] kg/s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("CGS base units")
|
||||
@@ -381,9 +381,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 × 10⁵ cm⋅g⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("unit::ratio::num != 1 && unit::ratio::den != 1")
|
||||
@@ -394,9 +394,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
// TODO(chogg): Reinstate after format/Magnitude design.
|
||||
// SECTION("iostream") { CHECK(os.str() == "30 [6 × 10⁻²] 1/m ⋅ s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("exponent::num == 1 && exponent::den == 1")
|
||||
@@ -406,9 +406,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "8 m⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("exponent::num == 2 && exponent::den == 1 for positive exponent")
|
||||
@@ -418,9 +418,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "16 m⋅s²"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("exponent::num == 2 && exponent::den == 1 for negative exponent (first dimension)")
|
||||
@@ -430,9 +430,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 1/m²⋅s"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("exponent::num == 2 && exponent::den == 1 for negative exponent (not first dimension)")
|
||||
@@ -442,9 +442,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "2 m/kg²"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("fractional positive exponent")
|
||||
@@ -454,9 +454,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "3 m^(1/2)"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
|
||||
SECTION("fractional negative exponent")
|
||||
@@ -466,9 +466,9 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("iostream") { CHECK(os.str() == "3 1/m^(1/2)"); }
|
||||
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); }
|
||||
SECTION("fmt with default format {} on a quantity") { CHECK(UNITS_STD_FMT::format("{}", q) == os.str()); }
|
||||
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -477,27 +477,27 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text]
|
||||
{
|
||||
SECTION("integral representation")
|
||||
{
|
||||
SECTION("positive value") { CHECK(STD_FMT::format("{:%Q}", 123_q_km_per_h) == "123"); }
|
||||
SECTION("positive value") { CHECK(UNITS_STD_FMT::format("{:%Q}", 123_q_km_per_h) == "123"); }
|
||||
|
||||
SECTION("negative value") { CHECK(STD_FMT::format("{:%Q}", 5_q_m - 10_q_m) == "-5"); }
|
||||
SECTION("negative value") { CHECK(UNITS_STD_FMT::format("{:%Q}", 5_q_m - 10_q_m) == "-5"); }
|
||||
}
|
||||
|
||||
SECTION("floating-point representation")
|
||||
{
|
||||
SECTION("positive value") { CHECK(STD_FMT::format("{:%Q}", 221._q_km / 2_q_h) == "110.5"); }
|
||||
SECTION("positive value") { CHECK(UNITS_STD_FMT::format("{:%Q}", 221._q_km / 2_q_h) == "110.5"); }
|
||||
|
||||
SECTION("negative value") { CHECK(STD_FMT::format("{:%Q}", 3.14_q_m - 10_q_m) == "-6.86"); }
|
||||
SECTION("negative value") { CHECK(UNITS_STD_FMT::format("{:%Q}", 3.14_q_m - 10_q_m) == "-6.86"); }
|
||||
|
||||
SECTION("nan")
|
||||
{
|
||||
CHECK(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(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")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%Q}", length<metre>(-std::numeric_limits<double>::infinity())) == "-inf");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q}", length<metre>(-std::numeric_limits<double>::infinity())) == "-inf");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,42 +506,42 @@ TEST_CASE("format string with only %q should print quantity unit symbol only", "
|
||||
{
|
||||
SECTION("standard format for a unit without Unicode symbols")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%q}", 123_q_km_per_h) == "km/h");
|
||||
CHECK(UNITS_STD_FMT::format("{:%q}", 123_q_km_per_h) == "km/h");
|
||||
}
|
||||
|
||||
SECTION("ASCII format for a unit without Unicode symbols")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%Aq}", 123_q_km_per_h) == "km/h");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Aq}", 123_q_km_per_h) == "km/h");
|
||||
}
|
||||
|
||||
SECTION("standard format for a unit with Unicode symbols")
|
||||
{
|
||||
SECTION("Unicode signs in a unit symbol") { CHECK(STD_FMT::format("{:%q}", 123_q_kR) == "kΩ"); }
|
||||
SECTION("Unicode signs in a unit symbol") { CHECK(UNITS_STD_FMT::format("{:%q}", 123_q_kR) == "kΩ"); }
|
||||
|
||||
SECTION("Unicode signs in a unit symbol prefix") { CHECK(STD_FMT::format("{:%q}", 123_q_uV) == "µV"); }
|
||||
SECTION("Unicode signs in a unit symbol prefix") { CHECK(UNITS_STD_FMT::format("{:%q}", 123_q_uV) == "µV"); }
|
||||
}
|
||||
|
||||
SECTION("ASCII format for a unit with Unicode symbols")
|
||||
{
|
||||
SECTION("Unicode signs in a unit symbol") { CHECK(STD_FMT::format("{:%Aq}", 123_q_kR) == "kohm"); }
|
||||
SECTION("Unicode signs in a unit symbol") { CHECK(UNITS_STD_FMT::format("{:%Aq}", 123_q_kR) == "kohm"); }
|
||||
|
||||
SECTION("Unicode signs in a unit symbol prefix") { CHECK(STD_FMT::format("{:%Aq}", 123_q_uV) == "uV"); }
|
||||
SECTION("Unicode signs in a unit symbol prefix") { CHECK(UNITS_STD_FMT::format("{:%Aq}", 123_q_uV) == "uV"); }
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("%q and %Q can be put anywhere in a format string", "[text][fmt]")
|
||||
{
|
||||
SECTION("no space") { CHECK(STD_FMT::format("{:%Q%q}", 123_q_km_per_h) == "123km/h"); }
|
||||
SECTION("no space") { CHECK(UNITS_STD_FMT::format("{:%Q%q}", 123_q_km_per_h) == "123km/h"); }
|
||||
|
||||
SECTION("separator") { CHECK(STD_FMT::format("{:%Q###%q}", 123_q_km_per_h) == "123###km/h"); }
|
||||
SECTION("separator") { CHECK(UNITS_STD_FMT::format("{:%Q###%q}", 123_q_km_per_h) == "123###km/h"); }
|
||||
|
||||
SECTION("opposite order") { CHECK(STD_FMT::format("{:%q %Q}", 123_q_km_per_h) == "km/h 123"); }
|
||||
SECTION("opposite order") { CHECK(UNITS_STD_FMT::format("{:%q %Q}", 123_q_km_per_h) == "km/h 123"); }
|
||||
|
||||
SECTION("tabulator") { CHECK(STD_FMT::format("{:%Q%t%q}", 123_q_km_per_h) == "123\tkm/h"); }
|
||||
SECTION("tabulator") { CHECK(UNITS_STD_FMT::format("{:%Q%t%q}", 123_q_km_per_h) == "123\tkm/h"); }
|
||||
|
||||
SECTION("new line") { CHECK(STD_FMT::format("{:%Q%n%q}", 123_q_km_per_h) == "123\nkm/h"); }
|
||||
SECTION("new line") { CHECK(UNITS_STD_FMT::format("{:%Q%n%q}", 123_q_km_per_h) == "123\nkm/h"); }
|
||||
|
||||
SECTION("% sign") { CHECK(STD_FMT::format("{:%Q%% %q}", 123_q_km_per_h) == "123% km/h"); }
|
||||
SECTION("% sign") { CHECK(UNITS_STD_FMT::format("{:%Q%% %q}", 123_q_km_per_h) == "123% km/h"); }
|
||||
}
|
||||
|
||||
TEST_CASE("fill and align specification", "[text][fmt][ostream]")
|
||||
@@ -589,50 +589,50 @@ TEST_CASE("fill and align specification", "[text][fmt][ostream]")
|
||||
|
||||
SECTION("default format {} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("|{:0}|", 123_q_m) == "|123 m|");
|
||||
CHECK(STD_FMT::format("|{:10}|", 123_q_m) == "| 123 m|");
|
||||
CHECK(STD_FMT::format("|{:<10}|", 123_q_m) == "|123 m |");
|
||||
CHECK(STD_FMT::format("|{:>10}|", 123_q_m) == "| 123 m|");
|
||||
CHECK(STD_FMT::format("|{:^10}|", 123_q_m) == "| 123 m |");
|
||||
CHECK(STD_FMT::format("|{:*<10}|", 123_q_m) == "|123 m*****|");
|
||||
CHECK(STD_FMT::format("|{:*>10}|", 123_q_m) == "|*****123 m|");
|
||||
CHECK(STD_FMT::format("|{:*^10}|", 123_q_m) == "|**123 m***|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:0}|", 123_q_m) == "|123 m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:10}|", 123_q_m) == "| 123 m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:<10}|", 123_q_m) == "|123 m |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:>10}|", 123_q_m) == "| 123 m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:^10}|", 123_q_m) == "| 123 m |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*<10}|", 123_q_m) == "|123 m*****|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*>10}|", 123_q_m) == "|*****123 m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*^10}|", 123_q_m) == "|**123 m***|");
|
||||
}
|
||||
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("|{:0%Q%q}|", 123_q_m) == "|123m|");
|
||||
CHECK(STD_FMT::format("|{:10%Q%q}|", 123_q_m) == "| 123m|");
|
||||
CHECK(STD_FMT::format("|{:<10%Q%q}|", 123_q_m) == "|123m |");
|
||||
CHECK(STD_FMT::format("|{:>10%Q%q}|", 123_q_m) == "| 123m|");
|
||||
CHECK(STD_FMT::format("|{:^10%Q%q}|", 123_q_m) == "| 123m |");
|
||||
CHECK(STD_FMT::format("|{:*<10%Q%q}|", 123_q_m) == "|123m******|");
|
||||
CHECK(STD_FMT::format("|{:*>10%Q%q}|", 123_q_m) == "|******123m|");
|
||||
CHECK(STD_FMT::format("|{:*^10%Q%q}|", 123_q_m) == "|***123m***|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:0%Q%q}|", 123_q_m) == "|123m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:10%Q%q}|", 123_q_m) == "| 123m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:<10%Q%q}|", 123_q_m) == "|123m |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:>10%Q%q}|", 123_q_m) == "| 123m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:^10%Q%q}|", 123_q_m) == "| 123m |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*<10%Q%q}|", 123_q_m) == "|123m******|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*>10%Q%q}|", 123_q_m) == "|******123m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*^10%Q%q}|", 123_q_m) == "|***123m***|");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("|{:0%Q}|", 123_q_m) == "|123|");
|
||||
CHECK(STD_FMT::format("|{:10%Q}|", 123_q_m) == "| 123|");
|
||||
CHECK(STD_FMT::format("|{:<10%Q}|", 123_q_m) == "|123 |");
|
||||
CHECK(STD_FMT::format("|{:>10%Q}|", 123_q_m) == "| 123|");
|
||||
CHECK(STD_FMT::format("|{:^10%Q}|", 123_q_m) == "| 123 |");
|
||||
CHECK(STD_FMT::format("|{:*<10%Q}|", 123_q_m) == "|123*******|");
|
||||
CHECK(STD_FMT::format("|{:*>10%Q}|", 123_q_m) == "|*******123|");
|
||||
CHECK(STD_FMT::format("|{:*^10%Q}|", 123_q_m) == "|***123****|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:0%Q}|", 123_q_m) == "|123|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:10%Q}|", 123_q_m) == "| 123|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:<10%Q}|", 123_q_m) == "|123 |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:>10%Q}|", 123_q_m) == "| 123|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:^10%Q}|", 123_q_m) == "| 123 |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*<10%Q}|", 123_q_m) == "|123*******|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*>10%Q}|", 123_q_m) == "|*******123|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*^10%Q}|", 123_q_m) == "|***123****|");
|
||||
}
|
||||
|
||||
SECTION("symbol only format {:%q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("|{:0%q}|", 123_q_m) == "|m|");
|
||||
CHECK(STD_FMT::format("|{:10%q}|", 123_q_m) == "|m |");
|
||||
CHECK(STD_FMT::format("|{:<10%q}|", 123_q_m) == "|m |");
|
||||
CHECK(STD_FMT::format("|{:>10%q}|", 123_q_m) == "| m|");
|
||||
CHECK(STD_FMT::format("|{:^10%q}|", 123_q_m) == "| m |");
|
||||
CHECK(STD_FMT::format("|{:*<10%q}|", 123_q_m) == "|m*********|");
|
||||
CHECK(STD_FMT::format("|{:*>10%q}|", 123_q_m) == "|*********m|");
|
||||
CHECK(STD_FMT::format("|{:*^10%q}|", 123_q_m) == "|****m*****|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:0%q}|", 123_q_m) == "|m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:10%q}|", 123_q_m) == "|m |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:<10%q}|", 123_q_m) == "|m |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:>10%q}|", 123_q_m) == "| m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:^10%q}|", 123_q_m) == "| m |");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*<10%q}|", 123_q_m) == "|m*********|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*>10%q}|", 123_q_m) == "|*********m|");
|
||||
CHECK(UNITS_STD_FMT::format("|{:*^10%q}|", 123_q_m) == "|****m*****|");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,18 +643,18 @@ TEST_CASE("sign specification", "[text][fmt]")
|
||||
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", 1_q_m) == "1m,+1m,1m, 1m");
|
||||
CHECK(STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", -1_q_m) == "-1m,-1m,-1m,-1m");
|
||||
CHECK(STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", inf) == "infm,+infm,infm, infm");
|
||||
CHECK(STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", nan) == "nanm,+nanm,nanm, nanm");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", 1_q_m) == "1m,+1m,1m, 1m");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", -1_q_m) == "-1m,-1m,-1m,-1m");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", inf) == "infm,+infm,infm, infm");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q%q},{0:%+Q%q},{0:%-Q%q},{0:% Q%q}", nan) == "nanm,+nanm,nanm, nanm");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", 1_q_m) == "1,+1,1, 1");
|
||||
CHECK(STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", -1_q_m) == "-1,-1,-1,-1");
|
||||
CHECK(STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", inf) == "inf,+inf,inf, inf");
|
||||
CHECK(STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", nan) == "nan,+nan,nan, nan");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", 1_q_m) == "1,+1,1, 1");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", -1_q_m) == "-1,-1,-1,-1");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", inf) == "inf,+inf,inf, inf");
|
||||
CHECK(UNITS_STD_FMT::format("{0:%Q},{0:%+Q},{0:%-Q},{0:% Q}", nan) == "nan,+nan,nan, nan");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,32 +662,32 @@ TEST_CASE("precision specification", "[text][fmt]")
|
||||
{
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%.0Q %q}", 1.2345_q_m) == "1 m");
|
||||
CHECK(STD_FMT::format("{:%.1Q %q}", 1.2345_q_m) == "1.2 m");
|
||||
CHECK(STD_FMT::format("{:%.2Q %q}", 1.2345_q_m) == "1.23 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.0Q %q}", 1.2345_q_m) == "1 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.1Q %q}", 1.2345_q_m) == "1.2 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.2Q %q}", 1.2345_q_m) == "1.23 m");
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
CHECK(STD_FMT::format("{:%.3Q %q}", 1.2345_q_m) == "1.234 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3Q %q}", 1.2345_q_m) == "1.234 m");
|
||||
#else
|
||||
CHECK(STD_FMT::format("{:%.3Q %q}", 1.2345_q_m) == "1.235 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3Q %q}", 1.2345_q_m) == "1.235 m");
|
||||
#endif
|
||||
CHECK(STD_FMT::format("{:%.4Q %q}", 1.2345_q_m) == "1.2345 m");
|
||||
CHECK(STD_FMT::format("{:%.5Q %q}", 1.2345_q_m) == "1.23450 m");
|
||||
CHECK(STD_FMT::format("{:%.10Q %q}", 1.2345_q_m) == "1.2345000000 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.4Q %q}", 1.2345_q_m) == "1.2345 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.5Q %q}", 1.2345_q_m) == "1.23450 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.10Q %q}", 1.2345_q_m) == "1.2345000000 m");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%.0Q}", 1.2345_q_m) == "1");
|
||||
CHECK(STD_FMT::format("{:%.1Q}", 1.2345_q_m) == "1.2");
|
||||
CHECK(STD_FMT::format("{:%.2Q}", 1.2345_q_m) == "1.23");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.0Q}", 1.2345_q_m) == "1");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.1Q}", 1.2345_q_m) == "1.2");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.2Q}", 1.2345_q_m) == "1.23");
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
CHECK(STD_FMT::format("{:%.3Q}", 1.2345_q_m) == "1.234");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3Q}", 1.2345_q_m) == "1.234");
|
||||
#else
|
||||
CHECK(STD_FMT::format("{:%.3Q}", 1.2345_q_m) == "1.235");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3Q}", 1.2345_q_m) == "1.235");
|
||||
#endif
|
||||
CHECK(STD_FMT::format("{:%.4Q}", 1.2345_q_m) == "1.2345");
|
||||
CHECK(STD_FMT::format("{:%.5Q}", 1.2345_q_m) == "1.23450");
|
||||
CHECK(STD_FMT::format("{:%.10Q}", 1.2345_q_m) == "1.2345000000");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.4Q}", 1.2345_q_m) == "1.2345");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.5Q}", 1.2345_q_m) == "1.23450");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.10Q}", 1.2345_q_m) == "1.2345000000");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,13 +695,13 @@ TEST_CASE("precision specification for integral representation should throw", "[
|
||||
{
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
REQUIRE_THROWS_MATCHES(STD_FMT::vformat("{:%.1Q %q}", STD_FMT::make_format_args(1_q_m)), 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(STD_FMT::vformat("{:%.1Q}", STD_FMT::make_format_args(1_q_m)), 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"));
|
||||
}
|
||||
}
|
||||
@@ -710,84 +710,84 @@ TEST_CASE("type specification", "[text][fmt]")
|
||||
{
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%bQ %q}", 42_q_m) == "101010 m");
|
||||
CHECK(STD_FMT::format("{:%BQ %q}", 42_q_m) == "101010 m");
|
||||
CHECK(STD_FMT::format("{:%dQ %q}", 42_q_m) == "42 m");
|
||||
CHECK(STD_FMT::format("{:%oQ %q}", 42_q_m) == "52 m");
|
||||
CHECK(STD_FMT::format("{:%xQ %q}", 42_q_m) == "2a m");
|
||||
CHECK(STD_FMT::format("{:%XQ %q}", 42_q_m) == "2A m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%bQ %q}", 42_q_m) == "101010 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%BQ %q}", 42_q_m) == "101010 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%dQ %q}", 42_q_m) == "42 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%oQ %q}", 42_q_m) == "52 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%xQ %q}", 42_q_m) == "2a m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%XQ %q}", 42_q_m) == "2A m");
|
||||
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
#if UNITS_USE_LIBFMT
|
||||
CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0 m");
|
||||
CHECK(STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "0x1.3c1p+0 m");
|
||||
CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0 m");
|
||||
CHECK(STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "0X1.3C1P+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "0x1.3c1p+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "0X1.3C1P+0 m");
|
||||
#else
|
||||
CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0 m");
|
||||
CHECK(STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "1.3c1p+0 m");
|
||||
CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0 m");
|
||||
CHECK(STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "1.3C1P+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "1.3c1p+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "1.3C1P+0 m");
|
||||
#endif // UNITS_USE_LIBFMT
|
||||
#else
|
||||
CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3 m");
|
||||
CHECK(STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "0x9.e06p-3 m");
|
||||
CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3 m");
|
||||
CHECK(STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "0X9.E06P-3 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "0x9.e06p-3 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "0X9.E06P-3 m");
|
||||
#endif
|
||||
CHECK(STD_FMT::format("{:%eQ %q}", 1.2345678_q_m) == "1.234568e+00 m");
|
||||
CHECK(STD_FMT::format("{:%.3eQ %q}", 1.2345678_q_m) == "1.235e+00 m");
|
||||
CHECK(STD_FMT::format("{:%EQ %q}", 1.2345678_q_m) == "1.234568E+00 m");
|
||||
CHECK(STD_FMT::format("{:%.3EQ %q}", 1.2345678_q_m) == "1.235E+00 m");
|
||||
CHECK(STD_FMT::format("{:%gQ %q}", 1.2345678_q_m) == "1.23457 m");
|
||||
CHECK(STD_FMT::format("{:%gQ %q}", 1.2345678e8_q_m) == "1.23457e+08 m");
|
||||
CHECK(STD_FMT::format("{:%.3gQ %q}", 1.2345678_q_m) == "1.23 m");
|
||||
CHECK(STD_FMT::format("{:%.3gQ %q}", 1.2345678e8_q_m) == "1.23e+08 m");
|
||||
CHECK(STD_FMT::format("{:%GQ %q}", 1.2345678_q_m) == "1.23457 m");
|
||||
CHECK(STD_FMT::format("{:%GQ %q}", 1.2345678e8_q_m) == "1.23457E+08 m");
|
||||
CHECK(STD_FMT::format("{:%.3GQ %q}", 1.2345678_q_m) == "1.23 m");
|
||||
CHECK(STD_FMT::format("{:%.3GQ %q}", 1.2345678e8_q_m) == "1.23E+08 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%eQ %q}", 1.2345678_q_m) == "1.234568e+00 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3eQ %q}", 1.2345678_q_m) == "1.235e+00 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%EQ %q}", 1.2345678_q_m) == "1.234568E+00 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3EQ %q}", 1.2345678_q_m) == "1.235E+00 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%gQ %q}", 1.2345678_q_m) == "1.23457 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%gQ %q}", 1.2345678e8_q_m) == "1.23457e+08 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3gQ %q}", 1.2345678_q_m) == "1.23 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3gQ %q}", 1.2345678e8_q_m) == "1.23e+08 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%GQ %q}", 1.2345678_q_m) == "1.23457 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%GQ %q}", 1.2345678e8_q_m) == "1.23457E+08 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3GQ %q}", 1.2345678_q_m) == "1.23 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3GQ %q}", 1.2345678e8_q_m) == "1.23E+08 m");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%bQ}", 42_q_m) == "101010");
|
||||
CHECK(STD_FMT::format("{:%BQ}", 42_q_m) == "101010");
|
||||
CHECK(STD_FMT::format("{:%dQ}", 42_q_m) == "42");
|
||||
CHECK(STD_FMT::format("{:%oQ}", 42_q_m) == "52");
|
||||
CHECK(STD_FMT::format("{:%xQ}", 42_q_m) == "2a");
|
||||
CHECK(STD_FMT::format("{:%XQ}", 42_q_m) == "2A");
|
||||
CHECK(UNITS_STD_FMT::format("{:%bQ}", 42_q_m) == "101010");
|
||||
CHECK(UNITS_STD_FMT::format("{:%BQ}", 42_q_m) == "101010");
|
||||
CHECK(UNITS_STD_FMT::format("{:%dQ}", 42_q_m) == "42");
|
||||
CHECK(UNITS_STD_FMT::format("{:%oQ}", 42_q_m) == "52");
|
||||
CHECK(UNITS_STD_FMT::format("{:%xQ}", 42_q_m) == "2a");
|
||||
CHECK(UNITS_STD_FMT::format("{:%XQ}", 42_q_m) == "2A");
|
||||
|
||||
#ifdef UNITS_COMP_MSVC
|
||||
#if UNITS_USE_LIBFMT
|
||||
CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0");
|
||||
CHECK(STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "0x1.3c1p+0");
|
||||
CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0");
|
||||
CHECK(STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "0X1.3C1P+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "0x1.3c1p+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "0X1.3C1P+0");
|
||||
#else
|
||||
CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0");
|
||||
CHECK(STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "1.3c1p+0");
|
||||
CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0");
|
||||
CHECK(STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "1.3C1P+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "1.3c1p+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "1.3C1P+0");
|
||||
#endif // UNITS_USE_LIBFMT
|
||||
#else
|
||||
CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3");
|
||||
CHECK(STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "0x9.e06p-3");
|
||||
CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3");
|
||||
CHECK(STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "0X9.E06P-3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "0x9.e06p-3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "0X9.E06P-3");
|
||||
#endif
|
||||
CHECK(STD_FMT::format("{:%eQ}", 1.2345678_q_m) == "1.234568e+00");
|
||||
CHECK(STD_FMT::format("{:%.3eQ}", 1.2345678_q_m) == "1.235e+00");
|
||||
CHECK(STD_FMT::format("{:%EQ}", 1.2345678_q_m) == "1.234568E+00");
|
||||
CHECK(STD_FMT::format("{:%.3EQ}", 1.2345678_q_m) == "1.235E+00");
|
||||
CHECK(STD_FMT::format("{:%gQ}", 1.2345678_q_m) == "1.23457");
|
||||
CHECK(STD_FMT::format("{:%gQ}", 1.2345678e8_q_m) == "1.23457e+08");
|
||||
CHECK(STD_FMT::format("{:%.3gQ}", 1.2345678_q_m) == "1.23");
|
||||
CHECK(STD_FMT::format("{:%.3gQ}", 1.2345678e8_q_m) == "1.23e+08");
|
||||
CHECK(STD_FMT::format("{:%GQ}", 1.2345678_q_m) == "1.23457");
|
||||
CHECK(STD_FMT::format("{:%GQ}", 1.2345678e8_q_m) == "1.23457E+08");
|
||||
CHECK(STD_FMT::format("{:%.3GQ}", 1.2345678_q_m) == "1.23");
|
||||
CHECK(STD_FMT::format("{:%.3GQ}", 1.2345678e8_q_m) == "1.23E+08");
|
||||
CHECK(UNITS_STD_FMT::format("{:%eQ}", 1.2345678_q_m) == "1.234568e+00");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3eQ}", 1.2345678_q_m) == "1.235e+00");
|
||||
CHECK(UNITS_STD_FMT::format("{:%EQ}", 1.2345678_q_m) == "1.234568E+00");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3EQ}", 1.2345678_q_m) == "1.235E+00");
|
||||
CHECK(UNITS_STD_FMT::format("{:%gQ}", 1.2345678_q_m) == "1.23457");
|
||||
CHECK(UNITS_STD_FMT::format("{:%gQ}", 1.2345678e8_q_m) == "1.23457e+08");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3gQ}", 1.2345678_q_m) == "1.23");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3gQ}", 1.2345678e8_q_m) == "1.23e+08");
|
||||
CHECK(UNITS_STD_FMT::format("{:%GQ}", 1.2345678_q_m) == "1.23457");
|
||||
CHECK(UNITS_STD_FMT::format("{:%GQ}", 1.2345678e8_q_m) == "1.23457E+08");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3GQ}", 1.2345678_q_m) == "1.23");
|
||||
CHECK(UNITS_STD_FMT::format("{:%.3GQ}", 1.2345678e8_q_m) == "1.23E+08");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,20 +795,20 @@ TEST_CASE("different base types with the # specifier", "[text][fmt]")
|
||||
{
|
||||
SECTION("full format {:%Q %q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%#bQ %q}", 42_q_m) == "0b101010 m");
|
||||
CHECK(STD_FMT::format("{:%#BQ %q}", 42_q_m) == "0B101010 m");
|
||||
CHECK(STD_FMT::format("{:%#oQ %q}", 42_q_m) == "052 m");
|
||||
CHECK(STD_FMT::format("{:%#xQ %q}", 42_q_m) == "0x2a m");
|
||||
CHECK(STD_FMT::format("{:%#XQ %q}", 42_q_m) == "0X2A m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#bQ %q}", 42_q_m) == "0b101010 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#BQ %q}", 42_q_m) == "0B101010 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#oQ %q}", 42_q_m) == "052 m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#xQ %q}", 42_q_m) == "0x2a m");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#XQ %q}", 42_q_m) == "0X2A m");
|
||||
}
|
||||
|
||||
SECTION("value only format {:%Q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{:%#bQ}", 42_q_m) == "0b101010");
|
||||
CHECK(STD_FMT::format("{:%#BQ}", 42_q_m) == "0B101010");
|
||||
CHECK(STD_FMT::format("{:%#oQ}", 42_q_m) == "052");
|
||||
CHECK(STD_FMT::format("{:%#xQ}", 42_q_m) == "0x2a");
|
||||
CHECK(STD_FMT::format("{:%#XQ}", 42_q_m) == "0X2A");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#bQ}", 42_q_m) == "0b101010");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#BQ}", 42_q_m) == "0B101010");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#oQ}", 42_q_m) == "052");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#xQ}", 42_q_m) == "0x2a");
|
||||
CHECK(UNITS_STD_FMT::format("{:%#XQ}", 42_q_m) == "0X2A");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,8 +829,8 @@ TEST_CASE("localization with the 'L' specifier", "[text][fmt][localization]")
|
||||
|
||||
SECTION("full format {:%LQ %q} on a quantity")
|
||||
{
|
||||
CHECK(STD_FMT::format(grp2, "{:%LQ %q}", 299792458_q_m_per_s) == "2_99_79_24_58 m/s");
|
||||
CHECK(STD_FMT::format(grp3, "{:%LQ %q}", 299792458_q_m_per_s) == "299'792'458 m/s");
|
||||
CHECK(UNITS_STD_FMT::format(grp2, "{:%LQ %q}", 299792458_q_m_per_s) == "2_99_79_24_58 m/s");
|
||||
CHECK(UNITS_STD_FMT::format(grp3, "{:%LQ %q}", 299792458_q_m_per_s) == "299'792'458 m/s");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -46,289 +46,289 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]")
|
||||
{
|
||||
SECTION("time")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_ns) == "1 ns");
|
||||
CHECK(STD_FMT::format("{}", 1_q_us) == "1 µs");
|
||||
CHECK(STD_FMT::format("{}", 1_q_ms) == "1 ms");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_ns) == "1 ns");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_us) == "1 µs");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_ms) == "1 ms");
|
||||
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_us) == "1 us");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_us) == "1 us");
|
||||
}
|
||||
|
||||
SECTION("length")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_mm) == "1 mm");
|
||||
CHECK(STD_FMT::format("{}", 1_q_cm) == "1 cm");
|
||||
CHECK(STD_FMT::format("{}", 1_q_km) == "1 km");
|
||||
CHECK(STD_FMT::format("{}", 1 * ft) == "1 ft");
|
||||
CHECK(STD_FMT::format("{}", 1_q_ft_us) == "1 ft(us)");
|
||||
CHECK(STD_FMT::format("{}", 1_q_yd) == "1 yd");
|
||||
CHECK(STD_FMT::format("{}", 1_q_in) == "1 in");
|
||||
CHECK(STD_FMT::format("{}", 1_q_fathom) == "1 fathom");
|
||||
CHECK(STD_FMT::format("{}", 1_q_fathom_us) == "1 fathom(us)");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mi) == "1 mi");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mi_us) == "1 mi(us)");
|
||||
CHECK(STD_FMT::format("{}", 1_q_naut_mi) == "1 mi(naut)");
|
||||
CHECK(STD_FMT::format("{}", 1_q_ch) == "1 ch");
|
||||
CHECK(STD_FMT::format("{}", 1_q_rd) == "1 rd");
|
||||
CHECK(STD_FMT::format("{}", 1_q_thou) == "1 thou");
|
||||
CHECK(STD_FMT::format("{}", 1_q_pc) == "1 pc");
|
||||
CHECK(STD_FMT::format("{}", 1_q_ly) == "1 ly");
|
||||
CHECK(STD_FMT::format("{}", 1_q_pc) == "1 pc");
|
||||
CHECK(STD_FMT::format("{}", 1_q_angstrom) == "1 angstrom");
|
||||
CHECK(STD_FMT::format("{}", 1_q_au) == "1 au");
|
||||
CHECK(STD_FMT::format("{}", 1_q_pica_comp) == "1 pica(comp)");
|
||||
CHECK(STD_FMT::format("{}", 1_q_pica_prn) == "1 pica(prn)");
|
||||
CHECK(STD_FMT::format("{}", 1_q_point_comp) == "1 point(comp)");
|
||||
CHECK(STD_FMT::format("{}", 1_q_point_prn) == "1 point(prn)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mm) == "1 mm");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_cm) == "1 cm");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_km) == "1 km");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * ft) == "1 ft");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_ft_us) == "1 ft(us)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_yd) == "1 yd");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_in) == "1 in");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_fathom) == "1 fathom");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_fathom_us) == "1 fathom(us)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mi) == "1 mi");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mi_us) == "1 mi(us)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_naut_mi) == "1 mi(naut)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_ch) == "1 ch");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_rd) == "1 rd");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_thou) == "1 thou");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_pc) == "1 pc");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_ly) == "1 ly");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_pc) == "1 pc");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_angstrom) == "1 angstrom");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_au) == "1 au");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_pica_comp) == "1 pica(comp)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_pica_prn) == "1 pica(prn)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_point_comp) == "1 point(comp)");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_point_prn) == "1 point(prn)");
|
||||
}
|
||||
|
||||
SECTION("mass") { CHECK(STD_FMT::format("{}", 1_q_kg) == "1 kg"); }
|
||||
SECTION("mass") { CHECK(UNITS_STD_FMT::format("{}", 1_q_kg) == "1 kg"); }
|
||||
|
||||
SECTION("area")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_m2) == "1 m²");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mm2) == "1 mm²");
|
||||
CHECK(STD_FMT::format("{}", 1_q_cm2) == "1 cm²");
|
||||
CHECK(STD_FMT::format("{}", 1_q_km2) == "1 km²");
|
||||
CHECK(STD_FMT::format("{}", 1_q_ft2) == "1 ft²");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_m2) == "1 m²");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mm2) == "1 mm²");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_cm2) == "1 cm²");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_km2) == "1 km²");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_ft2) == "1 ft²");
|
||||
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_m2) == "1 m^2");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_mm2) == "1 mm^2");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_cm2) == "1 cm^2");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_km2) == "1 km^2");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_ft2) == "1 ft^2");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_m2) == "1 m^2");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_mm2) == "1 mm^2");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_cm2) == "1 cm^2");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_km2) == "1 km^2");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_ft2) == "1 ft^2");
|
||||
}
|
||||
|
||||
SECTION("density")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_kg_per_m3) == "1 kg/m³");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_kg_per_m3) == "1 kg/m^3");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kg_per_m3) == "1 kg/m³");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_kg_per_m3) == "1 kg/m^3");
|
||||
}
|
||||
|
||||
SECTION("resistance")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_R) == "1 Ω");
|
||||
CHECK(STD_FMT::format("{}", 1_q_kR) == "1 kΩ");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mR) == "1 mΩ");
|
||||
CHECK(STD_FMT::format("{}", 1_q_MR) == "1 MΩ");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_R) == "1 Ω");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kR) == "1 kΩ");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mR) == "1 mΩ");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_MR) == "1 MΩ");
|
||||
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_R) == "1 ohm");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_kR) == "1 kohm");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_mR) == "1 mohm");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_MR) == "1 Mohm");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_R) == "1 ohm");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_kR) == "1 kohm");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_mR) == "1 mohm");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_MR) == "1 Mohm");
|
||||
}
|
||||
|
||||
SECTION("voltage")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_V) == "1 V");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mV) == "1 mV");
|
||||
CHECK(STD_FMT::format("{}", 1_q_uV) == "1 µV");
|
||||
CHECK(STD_FMT::format("{}", 1_q_nV) == "1 nV");
|
||||
CHECK(STD_FMT::format("{}", 1_q_pV) == "1 pV");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_V) == "1 V");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mV) == "1 mV");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_uV) == "1 µV");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_nV) == "1 nV");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_pV) == "1 pV");
|
||||
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_uV) == "1 uV");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_uV) == "1 uV");
|
||||
}
|
||||
|
||||
SECTION("volume")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_m3) == "1 m³");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mm3) == "1 mm³");
|
||||
CHECK(STD_FMT::format("{}", 1_q_cm3) == "1 cm³");
|
||||
CHECK(STD_FMT::format("{}", 1_q_km3) == "1 km³");
|
||||
CHECK(STD_FMT::format("{}", 1_q_ft3) == "1 ft³");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_m3) == "1 m³");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mm3) == "1 mm³");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_cm3) == "1 cm³");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_km3) == "1 km³");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_ft3) == "1 ft³");
|
||||
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_m3) == "1 m^3");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_mm3) == "1 mm^3");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_cm3) == "1 cm^3");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_km3) == "1 km^3");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_ft3) == "1 ft^3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_m3) == "1 m^3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_mm3) == "1 mm^3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_cm3) == "1 cm^3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_km3) == "1 km^3");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_ft3) == "1 ft^3");
|
||||
}
|
||||
|
||||
SECTION("frequency")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_mHz) == "1 mHz");
|
||||
CHECK(STD_FMT::format("{}", 1_q_kHz) == "1 kHz");
|
||||
CHECK(STD_FMT::format("{}", 1_q_MHz) == "1 MHz");
|
||||
CHECK(STD_FMT::format("{}", 1_q_GHz) == "1 GHz");
|
||||
CHECK(STD_FMT::format("{}", 1_q_THz) == "1 THz");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mHz) == "1 mHz");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kHz) == "1 kHz");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_MHz) == "1 MHz");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_GHz) == "1 GHz");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_THz) == "1 THz");
|
||||
}
|
||||
|
||||
SECTION("speed")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_m_per_s) == "1 m/s");
|
||||
CHECK(STD_FMT::format("{}", 1_q_km_per_h) == "1 km/h");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mi_per_h) == "1 mi/h");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_m_per_s) == "1 m/s");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_km_per_h) == "1 km/h");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mi_per_h) == "1 mi/h");
|
||||
}
|
||||
|
||||
SECTION("acceleration")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_m_per_s2) == "1 m/s²");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_m_per_s2) == "1 m/s^2");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_m_per_s2) == "1 m/s²");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_m_per_s2) == "1 m/s^2");
|
||||
}
|
||||
|
||||
SECTION("momentum")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_kg_m_per_s) == "1 kg⋅m/s");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_kg_m_per_s) == "1 kg m/s");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kg_m_per_s) == "1 kg⋅m/s");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_kg_m_per_s) == "1 kg m/s");
|
||||
}
|
||||
|
||||
SECTION("energy")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_mJ) == "1 mJ");
|
||||
CHECK(STD_FMT::format("{}", 1_q_kJ) == "1 kJ");
|
||||
CHECK(STD_FMT::format("{}", 1_q_MJ) == "1 MJ");
|
||||
CHECK(STD_FMT::format("{}", 1_q_GJ) == "1 GJ");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mJ) == "1 mJ");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kJ) == "1 kJ");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_MJ) == "1 MJ");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_GJ) == "1 GJ");
|
||||
}
|
||||
|
||||
SECTION("power")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_mW) == "1 mW");
|
||||
CHECK(STD_FMT::format("{}", 1_q_kW) == "1 kW");
|
||||
CHECK(STD_FMT::format("{}", 1_q_MW) == "1 MW");
|
||||
CHECK(STD_FMT::format("{}", 1_q_GW) == "1 GW");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mW) == "1 mW");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kW) == "1 kW");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_MW) == "1 MW");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_GW) == "1 GW");
|
||||
}
|
||||
|
||||
SECTION("surface tension") { CHECK(STD_FMT::format("{}", 1_q_N_per_m) == "1 N/m"); }
|
||||
SECTION("surface tension") { CHECK(UNITS_STD_FMT::format("{}", 1_q_N_per_m) == "1 N/m"); }
|
||||
|
||||
SECTION("magnetic induction") { CHECK(STD_FMT::format("{}", 1_q_T) == "1 T"); }
|
||||
SECTION("magnetic induction") { CHECK(UNITS_STD_FMT::format("{}", 1_q_T) == "1 T"); }
|
||||
|
||||
SECTION("magnetic flux")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_Wb) == "1 Wb");
|
||||
CHECK(STD_FMT::format("{}", 1_q_G) == "1 G");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_Wb) == "1 Wb");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_G) == "1 G");
|
||||
}
|
||||
|
||||
SECTION("inductance")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_H) == "1 H");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mH) == "1 mH");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_H) == "1 H");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mH) == "1 mH");
|
||||
}
|
||||
|
||||
SECTION("conductance")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_S) == "1 S");
|
||||
CHECK(STD_FMT::format("{}", 1_q_nS) == "1 nS");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_S) == "1 S");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_nS) == "1 nS");
|
||||
}
|
||||
|
||||
SECTION("catalytic activity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_kat) == "1 kat");
|
||||
CHECK(STD_FMT::format("{}", 1_q_U) == "1 U");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kat) == "1 kat");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_U) == "1 U");
|
||||
}
|
||||
|
||||
SECTION("absorbed dose")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_Gy) == "1 Gy");
|
||||
CHECK(STD_FMT::format("{}", 1_q_kGy) == "1 kGy");
|
||||
CHECK(STD_FMT::format("{}", 1_q_mGy) == "1 mGy");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_Gy) == "1 Gy");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_kGy) == "1 kGy");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mGy) == "1 mGy");
|
||||
}
|
||||
|
||||
SECTION("addition with common ratio") { CHECK(STD_FMT::format("{}", 1_q_in + 1_q_yd) == "37 in"); }
|
||||
SECTION("addition with common ratio") { CHECK(UNITS_STD_FMT::format("{}", 1_q_in + 1_q_yd) == "37 in"); }
|
||||
|
||||
SECTION("current density")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_A_per_m2) == "1 A/m²");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_A_per_m2) == "1 A/m^2");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_A_per_m2) == "1 A/m²");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_A_per_m2) == "1 A/m^2");
|
||||
}
|
||||
|
||||
SECTION("concentration")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_mol_per_m3) == "1 mol/m³");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_mol_per_m3) == "1 mol/m^3");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_mol_per_m3) == "1 mol/m³");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_mol_per_m3) == "1 mol/m^3");
|
||||
}
|
||||
|
||||
SECTION("luminance")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_cd_per_m2) == "1 cd/m²");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_cd_per_m2) == "1 cd/m^2");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_cd_per_m2) == "1 cd/m²");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_cd_per_m2) == "1 cd/m^2");
|
||||
}
|
||||
|
||||
SECTION("dynamic viscosity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_Pa_s) == "1 Pa⋅s");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_Pa_s) == "1 Pa s");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_Pa_s) == "1 Pa⋅s");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_Pa_s) == "1 Pa s");
|
||||
}
|
||||
|
||||
SECTION("heat capacity") { CHECK(STD_FMT::format("{}", 1_q_J_per_K) == "1 J/K"); }
|
||||
SECTION("heat capacity") { CHECK(UNITS_STD_FMT::format("{}", 1_q_J_per_K) == "1 J/K"); }
|
||||
|
||||
SECTION("specific heat capacity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_J_per_kg_K) == "1 J⋅K⁻¹⋅kg⁻¹");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_J_per_kg_K) == "1 J K^-1 kg^-1");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_J_per_kg_K) == "1 J⋅K⁻¹⋅kg⁻¹");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_J_per_kg_K) == "1 J K^-1 kg^-1");
|
||||
}
|
||||
|
||||
SECTION("molar heath capacity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_J_per_mol_K) == "1 J⋅K⁻¹⋅mol⁻¹");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_J_per_mol_K) == "1 J K^-1 mol^-1");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_J_per_mol_K) == "1 J⋅K⁻¹⋅mol⁻¹");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_J_per_mol_K) == "1 J K^-1 mol^-1");
|
||||
}
|
||||
|
||||
SECTION("thermal conductivity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_W_per_m_K) == "1 W⋅m⁻¹⋅K⁻¹");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_W_per_m_K) == "1 W m^-1 K^-1");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_W_per_m_K) == "1 W⋅m⁻¹⋅K⁻¹");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_W_per_m_K) == "1 W m^-1 K^-1");
|
||||
}
|
||||
|
||||
SECTION("electric field strength") { CHECK(STD_FMT::format("{}", 1_q_V_per_m) == "1 V/m"); }
|
||||
SECTION("electric field strength") { CHECK(UNITS_STD_FMT::format("{}", 1_q_V_per_m) == "1 V/m"); }
|
||||
|
||||
SECTION("charge density")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1_q_C_per_m3) == "1 C/m³");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_C_per_m3) == "1 C/m^3");
|
||||
CHECK(STD_FMT::format("{}", 1_q_C_per_m2) == "1 C/m²");
|
||||
CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_C_per_m2) == "1 C/m^2");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_C_per_m3) == "1 C/m³");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_C_per_m3) == "1 C/m^3");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1_q_C_per_m2) == "1 C/m²");
|
||||
CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", 1_q_C_per_m2) == "1 C/m^2");
|
||||
}
|
||||
|
||||
SECTION("permittivity") { CHECK(STD_FMT::format("{}", 1_q_F_per_m) == "1 F/m"); }
|
||||
SECTION("permittivity") { CHECK(UNITS_STD_FMT::format("{}", 1_q_F_per_m) == "1 F/m"); }
|
||||
|
||||
SECTION("permeability") { CHECK(STD_FMT::format("{}", 1_q_H_per_m) == "1 H/m"); }
|
||||
SECTION("permeability") { CHECK(UNITS_STD_FMT::format("{}", 1_q_H_per_m) == "1 H/m"); }
|
||||
|
||||
SECTION("molar energy") { CHECK(STD_FMT::format("{}", 1_q_J_per_mol) == "1 J/mol"); }
|
||||
SECTION("molar energy") { CHECK(UNITS_STD_FMT::format("{}", 1_q_J_per_mol) == "1 J/mol"); }
|
||||
|
||||
SECTION("torque") { CHECK(STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N⋅m/rad"); }
|
||||
SECTION("torque") { CHECK(UNITS_STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N⋅m/rad"); }
|
||||
|
||||
SECTION("storage_capacity")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1 * bit) == "1 bit");
|
||||
CHECK(STD_FMT::format("{}", 1 * kbit) == "1 kbit");
|
||||
CHECK(STD_FMT::format("{}", 1 * Tibit) == "1 Tibit");
|
||||
CHECK(STD_FMT::format("{}", 1 * B) == "1 B");
|
||||
CHECK(STD_FMT::format("{}", 1 * kB) == "1 kB");
|
||||
CHECK(STD_FMT::format("{}", 1 * TiB) == "1 TiB");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * bit) == "1 bit");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * kbit) == "1 kbit");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * Tibit) == "1 Tibit");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * B) == "1 B");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * kB) == "1 kB");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * TiB) == "1 TiB");
|
||||
}
|
||||
|
||||
SECTION("transfer_rate")
|
||||
{
|
||||
CHECK(STD_FMT::format("{}", 1 * (B / s)) == "1 B/s");
|
||||
CHECK(STD_FMT::format("{}", 1 * (kB / s)) == "1 kB/s");
|
||||
CHECK(STD_FMT::format("{}", 1 * (TB / s)) == "1 TB/s");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * (B / s)) == "1 B/s");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * (kB / s)) == "1 kB/s");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * (TB / s)) == "1 TB/s");
|
||||
}
|
||||
|
||||
SECTION("traffic_intesity") { CHECK(STD_FMT::format("{}", 1 * E) == "1 E"); }
|
||||
SECTION("traffic_intesity") { CHECK(UNITS_STD_FMT::format("{}", 1 * E) == "1 E"); }
|
||||
|
||||
SECTION("modulation_rate")
|
||||
{
|
||||
using namespace units::isq::iec80000;
|
||||
CHECK(STD_FMT::format("{}", 1 * Bd) == "1 Bd");
|
||||
CHECK(STD_FMT::format("{}", 1 * kBd) == "1 kBd");
|
||||
CHECK(STD_FMT::format("{}", 1 * TBd) == "1 TBd");
|
||||
CHECK(STD_FMT::format("{}", quantity_cast<baud>(4 / (2 * s))) == "2 Bd");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * Bd) == "1 Bd");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * kBd) == "1 kBd");
|
||||
CHECK(UNITS_STD_FMT::format("{}", 1 * TBd) == "1 TBd");
|
||||
CHECK(UNITS_STD_FMT::format("{}", quantity_cast<baud>(4 / (2 * s))) == "2 Bd");
|
||||
}
|
||||
|
||||
SECTION("incoherent units with powers")
|
||||
{
|
||||
// TODO(chogg): Reinstate after format/Magnitude redesign.
|
||||
// CHECK(STD_FMT::format("{}", 1_q_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³");
|
||||
// CHECK(STD_FMT::format("{}", 1_q_au * 1_q_au) == "1 [2237952291797391849 × 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(STD_FMT::format("{:%Q %Aq}", 1_q_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 x 10^9] m^3");
|
||||
// CHECK(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")
|
||||
{
|
||||
// TODO(chogg): Reinstate after format/Magnitude redesign.
|
||||
// constexpr auto mag = units::mag<units::ratio{2, 3}>();
|
||||
// CHECK(STD_FMT::format("{}", mass<units::scaled_unit<mag, gram>>(1)) == "1 [2/3 × 10⁻³] kg");
|
||||
// CHECK(STD_FMT::format("{:%Q %Aq}", mass<units::scaled_unit<mag, gram>>(1)) == "1 [2/3 x 10^-3] kg");
|
||||
// CHECK(UNITS_STD_FMT::format("{}", mass<units::scaled_unit<mag, gram>>(1)) == "1 [2/3 × 10⁻³] kg");
|
||||
// CHECK(UNITS_STD_FMT::format("{:%Q %Aq}", mass<units::scaled_unit<mag, gram>>(1)) == "1 [2/3 x 10^-3] kg");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user