fix: according to ISO 80000-16 % should always be prefixed with space

This commit is contained in:
Mateusz Pusz
2024-10-03 11:54:40 +02:00
parent 1a8a386460
commit 51dc1d7469
2 changed files with 1 additions and 7 deletions

View File

@ -756,10 +756,6 @@ constexpr bool space_before_unit_symbol = true;
template<>
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<one> = false;
template<>
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<percent> = false;
template<>
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<per_mille> = false;
// get_unit_symbol

View File

@ -252,9 +252,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
constexpr auto q = value_cast<percent>(15. * isq::length[m] / (100. * isq::length[m]));
os << q;
static_assert(!space_before_unit_symbol<get_unit(q.reference)>);
SECTION("iostream") { CHECK(os.str() == "15%"); }
SECTION("iostream") { CHECK(os.str() == "15 %"); }
SECTION("fmt with default format {} on a quantity") { CHECK(MP_UNITS_STD_FMT::format("{}", q) == os.str()); }