diff --git a/src/include/units/bits/unit_text.h b/src/include/units/bits/unit_text.h index 0a45215e..0e0e26d9 100644 --- a/src/include/units/bits/unit_text.h +++ b/src/include/units/bits/unit_text.h @@ -145,12 +145,14 @@ constexpr auto unit_text() return U::symbol; } else { - // print as a prefix or ratio of a reference unit - auto prefix_txt = prefix_or_ratio_text(); + // print as a prefix or ratio of a coherent unit + using coherent_unit = dimension_unit; + using ratio = ratio_divide; + auto prefix_txt = prefix_or_ratio_text(); - if constexpr(has_symbol) { - // use predefined reference unit symbol - return prefix_txt + U::reference::symbol; + if constexpr(has_symbol) { + // use predefined coherent unit symbol + return prefix_txt + coherent_unit::symbol; } else { // use derived dimension ingredients to create a unit symbol diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 75c6415f..a1aebc6e 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -188,4 +188,9 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") CHECK(fmt::format("{}", 1q_mi * 1q_mi * 1q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³"); CHECK(fmt::format("{}", 1q_au * 1q_au) == "1 [2237952291797391849 × 10⁴] m²"); } + + SECTION("unknown scaled unit with reference different than the dimension's coherent unit") + { + CHECK(fmt::format("{}", mass, gram>>(1)) == "1 [2/3 × 10⁻³] kg"); + } }