mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 02:47:16 +02:00
More text output tests added
This commit is contained in:
@ -82,9 +82,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("quantity with a predefined unit + prefix")
|
SECTION("quantity with a predefined prefixed unit")
|
||||||
{
|
|
||||||
SECTION("in terms of base units")
|
|
||||||
{
|
{
|
||||||
const auto q = 125us;
|
const auto q = 125us;
|
||||||
stream << q;
|
stream << q;
|
||||||
@ -105,14 +103,37 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("in terms of derived units")
|
SECTION("quantity with a predefined unit + prefix")
|
||||||
{
|
{
|
||||||
const auto q = 60kJ;
|
SECTION("in terms of base units")
|
||||||
|
{
|
||||||
|
const quantity<unit<length, ratio<1'000'000>>> q(123);
|
||||||
stream << q;
|
stream << q;
|
||||||
|
|
||||||
SECTION("iostream")
|
SECTION("iostream")
|
||||||
{
|
{
|
||||||
REQUIRE(stream.str() == "60 kJ");
|
REQUIRE(stream.str() == "123 Mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("fmt with default format {} on a quantity")
|
||||||
|
{
|
||||||
|
REQUIRE(fmt::format("{}", q) == stream.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("fmt with format {:%Q %q} on a quantity")
|
||||||
|
{
|
||||||
|
REQUIRE(fmt::format("{:%Q %q}", q) == stream.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("in terms of derived units")
|
||||||
|
{
|
||||||
|
const quantity<unit<energy, ratio<1, 100>>> q(60);
|
||||||
|
stream << q;
|
||||||
|
|
||||||
|
SECTION("iostream")
|
||||||
|
{
|
||||||
|
REQUIRE(stream.str() == "60 cJ");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("fmt with default format {} on a quantity")
|
SECTION("fmt with default format {} on a quantity")
|
||||||
|
Reference in New Issue
Block a user