More fmt unit tests added

This commit is contained in:
Mateusz Pusz
2019-11-06 22:45:45 +00:00
parent 7fd92f034b
commit c6d2002ebd

View File

@ -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]")