mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 10:27: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("in terms of base units")
|
||||
SECTION("quantity with a predefined prefixed unit")
|
||||
{
|
||||
const auto q = 125us;
|
||||
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;
|
||||
|
||||
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")
|
||||
|
Reference in New Issue
Block a user