generic traits and debug format for enums

This commit is contained in:
2019-11-22 12:56:56 +07:00
parent 588c9d4f71
commit 46ac61f0cb
21 changed files with 142 additions and 41 deletions

View File

@@ -92,7 +92,12 @@ namespace
"f_" : "hi",
"vv" : [1,2,2,3],
"vv_" : "hello"
"vv_" : "hello",
"e0" : "pvr",
"e0_" : "hello",
"e1" : "rgb_etc1",
"e1_" : "hello"
})json";
}
@@ -433,4 +438,18 @@ TEST_CASE("json_utils") {
REQUIRE(v5 == v5_);
REQUIRE(v6 == v6_);
}
{
image_file_format e0 = image_file_format::dds;
image_data_format e1 = image_data_format::a8;
REQUIRE_FALSE(json_utils::try_parse_value(doc["e0_"], e0));
REQUIRE(e0 == image_file_format::dds);
REQUIRE(json_utils::try_parse_value(doc["e0"], e0));
REQUIRE(e0 == image_file_format::pvr);
REQUIRE_FALSE(json_utils::try_parse_value(doc["e1_"], e1));
REQUIRE(e1 == image_data_format::a8);
REQUIRE(json_utils::try_parse_value(doc["e1"], e1));
REQUIRE(e1 == image_data_format::rgb_etc1);
}
}

View File

@@ -170,4 +170,11 @@ TEST_CASE("strfmts") {
"%0",
strings::make_format_arg(make_aabb(1.f,2.f,3.f,4.f,5.f,6.f), u8(5), u8(2))) == "( 1.00, 2.00, 3.00, 4.00, 5.00, 6.00)");
}
{
REQUIRE(strings::rformat("%0", image_file_format::tga) == "tga");
REQUIRE(strings::rformat(
"%0",
strings::make_format_arg(image_file_format::dds, u8(5))) ==
" dds");
}
}