mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 11:54:27 +02:00
Standard vs Unicode formatting unit tests refactored
This commit is contained in:
@@ -703,33 +703,42 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text]
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("format string with only %q should print quantity unit symbol only", "[text][fmt]")
|
TEST_CASE("format string with only %q should print quantity unit symbol only", "[text][fmt]")
|
||||||
|
{
|
||||||
|
SECTION("standard format for a unit without Unicode symbols")
|
||||||
{
|
{
|
||||||
CHECK(fmt::format("{:%q}", 123q_km_per_h) == "km/h");
|
CHECK(fmt::format("{:%q}", 123q_km_per_h) == "km/h");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("format string with only %q for unit with ASCII quantity unit symbol should print Unicode quantity unit symbol only", "[text][fmt]")
|
SECTION("ASCII format for a unit without Unicode symbols")
|
||||||
{
|
|
||||||
CHECK(fmt::format("{:%Q%q}", 123q_kR) == "123kΩ");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("format string with %Aq for unit with ASCII quantity unit symbol should print ASCII quantity unit symbol only", "[text][fmt]")
|
|
||||||
{
|
|
||||||
CHECK(fmt::format("{:%Q%Aq}", 123q_kR) == "123kohm");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("format string with %Aq for unit with no ASCII quantity unit symbol should print Unicode quantity unit symbol only", "[text][fmt]")
|
|
||||||
{
|
{
|
||||||
CHECK(fmt::format("{:%Aq}", 123q_km_per_h) == "km/h");
|
CHECK(fmt::format("{:%Aq}", 123q_km_per_h) == "km/h");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("format string with only %q for unit with ASCII quantity unit prefix symbol should print Unicode quantity unit prefix symbol only", "[text][fmt]")
|
SECTION("standard format for a unit with Unicode symbols")
|
||||||
{
|
{
|
||||||
CHECK(fmt::format("{:%Q%q}", 123q_uV) == "123\u00b5V");
|
SECTION("Unicode signs in a unit symbol")
|
||||||
|
{
|
||||||
|
CHECK(fmt::format("{:%q}", 123q_kR) == "kΩ");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("format string with %Aq for unit with ASCII quantity unit prefix symbol should print ASCII quantity unit prefix symbol only", "[text][fmt]")
|
SECTION("Unicode signs in a unit symbol prefix")
|
||||||
{
|
{
|
||||||
CHECK(fmt::format("{:%Q%Aq}", 123q_uV) == "123uV");
|
CHECK(fmt::format("{:%q}", 123q_uV) == "µV");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("ASCII format for a unit with Unicode symbols")
|
||||||
|
{
|
||||||
|
SECTION("Unicode signs in a unit symbol")
|
||||||
|
{
|
||||||
|
CHECK(fmt::format("{:%Aq}", 123q_kR) == "kohm");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Unicode signs in a unit symbol prefix")
|
||||||
|
{
|
||||||
|
CHECK(fmt::format("{:%Aq}", 123q_uV) == "uV");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("%q and %Q can be put anywhere in a format string", "[text][fmt]")
|
TEST_CASE("%q and %Q can be put anywhere in a format string", "[text][fmt]")
|
||||||
|
Reference in New Issue
Block a user