Standard vs Unicode formatting unit tests refactored

This commit is contained in:
Mateusz Pusz
2020-05-05 21:26:30 +02:00
parent ff21e1e899
commit ffd3af42d2

View File

@@ -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]")
{
SECTION("standard format for a unit without Unicode symbols")
{
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]")
{
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]")
SECTION("ASCII format for a unit without Unicode symbols")
{
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) == "");
}
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]")