mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
small changes based on code review
This commit is contained in:
committed by
Mateusz Pusz
parent
509b6c9653
commit
0ad78fe753
@@ -35,12 +35,12 @@ constexpr auto ratio_text()
|
|||||||
return txt + basic_fixed_string("]");
|
return txt + basic_fixed_string("]");
|
||||||
}
|
}
|
||||||
else if constexpr (Ratio::den == 1) {
|
else if constexpr (Ratio::den == 1) {
|
||||||
return txt + basic_fixed_string(" x 10") + superscript<Ratio::exp>() +
|
return txt + basic_fixed_string(" \u00D7 10") + superscript<Ratio::exp>() +
|
||||||
basic_fixed_string("]");
|
basic_fixed_string("]");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return txt + basic_fixed_string("/") + regular<Ratio::den>() +
|
return txt + basic_fixed_string("/") + regular<Ratio::den>() +
|
||||||
basic_fixed_string(" x 10") + superscript<Ratio::exp>() +
|
basic_fixed_string(" \u00D7 10") + superscript<Ratio::exp>() +
|
||||||
basic_fixed_string("]");
|
basic_fixed_string("]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,31 +23,32 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <units/prefix.h>
|
#include <units/prefix.h>
|
||||||
#include <ratio>
|
|
||||||
|
|
||||||
namespace units::si {
|
namespace units::si {
|
||||||
|
|
||||||
struct prefix : prefix_type {};
|
struct prefix : prefix_type {};
|
||||||
|
|
||||||
// TODO Remove dependency on std::ratio
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
struct atto : units::prefix<atto, prefix, "a", ratio<1, 1, -18>> {}; // std::atto::den>> {};
|
|
||||||
struct femto : units::prefix<femto, prefix, "f", ratio<1, 1, -15>> {}; // std::femto::den>> {};
|
|
||||||
struct pico : units::prefix<pico, prefix, "p", ratio<1, 1, -12>> {}; // std::pico::den>> {};
|
|
||||||
struct nano : units::prefix<nano, prefix, "n", ratio<1, 1, -9>> {}; // std::nano::den>> {};
|
|
||||||
struct micro : units::prefix<micro, prefix, "\u00b5", ratio<1, 1, -6>> {}; // std::micro::den>> {};
|
|
||||||
struct milli : units::prefix<milli, prefix, "m", ratio<1, 1, -3>> {}; // std::milli::den>> {};
|
|
||||||
struct centi : units::prefix<centi, prefix, "c", ratio<1, 1, -2>> {}; // std::centi::den>> {};
|
|
||||||
struct deci : units::prefix<deci, prefix, "d", ratio<1, 1, -1>> {}; // std::deci::den>> {};
|
|
||||||
struct deca : units::prefix<deca, prefix, "da", ratio<1, 1, 1>> {}; // std::deca::num>> {};
|
|
||||||
struct hecto : units::prefix<hecto, prefix, "h", ratio<1, 1, 2>> {}; // std::hecto::num>> {};
|
|
||||||
struct kilo : units::prefix<kilo, prefix, "k", ratio<1, 1, 3>> {}; // std::kilo::num>> {};
|
|
||||||
struct mega : units::prefix<mega, prefix, "M", ratio<1, 1, 6>> {}; // std::mega::num>> {};
|
|
||||||
struct giga : units::prefix<giga, prefix, "G", ratio<1, 1, 9>> {}; // std::giga::num>> {};
|
|
||||||
struct tera : units::prefix<tera, prefix, "T", ratio<1, 1, 12>> {}; // std::tera::num>> {};
|
|
||||||
struct peta : units::prefix<peta, prefix, "P", ratio<1, 1, 15>> {}; // std::peta::num>> {};
|
|
||||||
struct exa : units::prefix<exa, prefix, "E", ratio<1, 1, 18>> {}; // std::exa::num>> {};
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
struct yocto : units::prefix<yocto, prefix, "y", ratio<1, 1, -24>> {};
|
||||||
|
struct zepto : units::prefix<zepto, prefix, "z", ratio<1, 1, -21>> {};
|
||||||
|
struct atto : units::prefix<atto, prefix, "a", ratio<1, 1, -18>> {};
|
||||||
|
struct femto : units::prefix<femto, prefix, "f", ratio<1, 1, -15>> {};
|
||||||
|
struct pico : units::prefix<pico, prefix, "p", ratio<1, 1, -12>> {};
|
||||||
|
struct nano : units::prefix<nano, prefix, "n", ratio<1, 1, -9>> {};
|
||||||
|
struct micro : units::prefix<micro, prefix, "\u00b5", ratio<1, 1, -6>> {};
|
||||||
|
struct milli : units::prefix<milli, prefix, "m", ratio<1, 1, -3>> {};
|
||||||
|
struct centi : units::prefix<centi, prefix, "c", ratio<1, 1, -2>> {};
|
||||||
|
struct deci : units::prefix<deci, prefix, "d", ratio<1, 1, -1>> {};
|
||||||
|
struct deca : units::prefix<deca, prefix, "da", ratio<1, 1, 1>> {};
|
||||||
|
struct hecto : units::prefix<hecto, prefix, "h", ratio<1, 1, 2>> {};
|
||||||
|
struct kilo : units::prefix<kilo, prefix, "k", ratio<1, 1, 3>> {};
|
||||||
|
struct mega : units::prefix<mega, prefix, "M", ratio<1, 1, 6>> {};
|
||||||
|
struct giga : units::prefix<giga, prefix, "G", ratio<1, 1, 9>> {};
|
||||||
|
struct tera : units::prefix<tera, prefix, "T", ratio<1, 1, 12>> {};
|
||||||
|
struct peta : units::prefix<peta, prefix, "P", ratio<1, 1, 15>> {};
|
||||||
|
struct exa : units::prefix<exa, prefix, "E", ratio<1, 1, 18>> {};
|
||||||
|
struct zetta : units::prefix<zetta, prefix, "Z", ratio<1, 1, 21>> {};
|
||||||
|
struct yotta : units::prefix<yotta, prefix, "Y", ratio<1, 1, 24>> {};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
} // namespace units::si
|
} // namespace units::si
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
// The MIT License (MIT)
|
// The MIT License (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2018 Mateusz Pusz
|
// Copyright (c) 2018 Mateusz Pusz
|
||||||
@@ -32,7 +33,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
|
@@ -296,7 +296,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "8 [1 x 10⁻²]m³");
|
CHECK(stream.str() == "8 [1 \u00D7 10⁻²]m³");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
@@ -317,7 +317,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "2 [6 x 10¹]Hz");
|
CHECK(stream.str() == "2 [6 \u00D7 10¹]Hz");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
@@ -338,7 +338,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "10 [1/6 x 10⁻¹]W");
|
CHECK(stream.str() == "10 [1/6 \u00D7 10⁻¹]W");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
@@ -359,7 +359,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "30 [1/6 x 10²]W");
|
CHECK(stream.str() == "30 [1/6 \u00D7 10²]W");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
@@ -404,7 +404,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "8 [1 x 10³]m⋅s");
|
CHECK(stream.str() == "8 [1 \u00D7 10³]m⋅s");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
@@ -425,7 +425,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "2 [6 x 10¹]kg/s");
|
CHECK(stream.str() == "2 [6 \u00D7 10¹]kg/s");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
@@ -446,7 +446,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "10 [1/6 x 10⁻¹]kg/s");
|
CHECK(stream.str() == "10 [1/6 \u00D7 10⁻¹]kg/s");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
@@ -467,7 +467,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
CHECK(stream.str() == "30 [6 x 10⁻²]1/m⋅s");
|
CHECK(stream.str() == "30 [6 \u00D7 10⁻²]1/m⋅s");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
|
Reference in New Issue
Block a user