Added tests for localization

This commit is contained in:
rbrugo
2020-09-10 01:31:42 +02:00
committed by Mateusz Pusz
parent 91761f0522
commit b0428d623a

View File

@ -1118,7 +1118,7 @@ TEST_CASE("type specification", "[text][fmt]")
}
}
TEST_CASE("different base types with the # specifier")
TEST_CASE("different base types with the # specifier", "[text][fmt]")
{
SECTION("full format {:%Q %q} on a quantity")
{
@ -1139,6 +1139,30 @@ TEST_CASE("different base types with the # specifier")
}
}
TEST_CASE("localization with the 'L' specifier", "[text][fmt][localization]")
{
struct group2 : std::numpunct<char>
{
char do_thousands_sep() const override { return '_'; }
std::string do_grouping() const override { return "\2"; }
};
struct group3 : std::numpunct<char>
{
char do_thousands_sep() const override { return '\''; }
std::string do_grouping() const override { return "\3"; }
};
std::locale grp2{std::locale::classic(), new group2};
std::locale grp3{std::locale::classic(), new group3};
SECTION("full format {:%LQ %q} on a quantity")
{
CHECK(fmt::format(grp2, "{:%LQ %q}", 299792458_q_m_per_s) == "2_99_79_24_58 m/s");
CHECK(fmt::format(grp3, "{:%LQ %q}", 299792458_q_m_per_s) == "299'792'458 m/s");
}
}
TEST_CASE("quantity_cast", "[text][ostream]")
{
std::ostringstream os;