diff --git a/src/core/include/mp-units/unit.h b/src/core/include/mp-units/unit.h index 79b2512a..cbcdde91 100644 --- a/src/core/include/mp-units/unit.h +++ b/src/core/include/mp-units/unit.h @@ -836,6 +836,11 @@ constexpr Out unit_symbol_impl(Out out, const derived_unit&, unit_symbo template inline constexpr bool space_before_unit_symbol = true; +template<> +inline constexpr bool space_before_unit_symbol = false; +template<> +inline constexpr bool space_before_unit_symbol = false; + template Out, Unit U> constexpr Out unit_symbol_to(Out out, U u, unit_symbol_formatting fmt = unit_symbol_formatting{}) { diff --git a/test/runtime/fmt_test.cpp b/test/runtime/fmt_test.cpp index 71ea8588..b1d131ec 100644 --- a/test/runtime/fmt_test.cpp +++ b/test/runtime/fmt_test.cpp @@ -233,11 +233,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = value_cast(15. * isq::length[m] / (100. * isq::length[m])); os << q; - 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()); } - SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(MP_UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(MP_UNITS_STD_FMT::format("{:%Q %q}", q) == "15 %"); } } SECTION("radians")