mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
More fmt unit tests added
This commit is contained in:
@ -567,15 +567,43 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text]
|
||||
{
|
||||
SECTION("integral representation")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", 123kmph) == "123");
|
||||
SECTION("positive value")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", 123kmph) == "123");
|
||||
}
|
||||
|
||||
SECTION("negative value")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", 5m - 10m) == "-5");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("floating-point representation")
|
||||
{
|
||||
SECTION("no precision specification")
|
||||
SECTION("positive value")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", 221.km / 2h) == "110.5");
|
||||
}
|
||||
|
||||
SECTION("negative value")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", 3.14m - 10m) == "-6.86");
|
||||
}
|
||||
|
||||
SECTION("nan")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", quantity<metre>(std::numeric_limits<double>::quiet_NaN())) == "nan");
|
||||
}
|
||||
|
||||
SECTION("inf")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", quantity<metre>(std::numeric_limits<double>::infinity())) == "inf");
|
||||
}
|
||||
|
||||
SECTION("-inf")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q}", quantity<metre>(-std::numeric_limits<double>::infinity())) == "-inf");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,6 +638,11 @@ TEST_CASE("%q an %Q can be put anywhere in a format string", "[text][fmt]")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q%n%q}", 123kmph) == "123\nkm/h");
|
||||
}
|
||||
|
||||
SECTION("% sign")
|
||||
{
|
||||
REQUIRE(fmt::format("{:%Q%% %q}", 123kmph) == "123% km/h");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("precision specification", "[text][fmt]")
|
||||
|
Reference in New Issue
Block a user