Improve format_as safety
This commit is contained in:
+6
-2
@@ -677,8 +677,11 @@ namespace test {
|
||||
enum class scoped_enum_as_int {};
|
||||
auto format_as(scoped_enum_as_int) -> int { return 42; }
|
||||
|
||||
enum class scoped_enum_as_string_view {};
|
||||
auto format_as(scoped_enum_as_string_view) -> fmt::string_view { return "foo"; }
|
||||
|
||||
enum class scoped_enum_as_string {};
|
||||
auto format_as(scoped_enum_as_string) -> fmt::string_view { return "foo"; }
|
||||
auto format_as(scoped_enum_as_string) -> std::string { return "foo"; }
|
||||
|
||||
struct struct_as_int {};
|
||||
auto format_as(struct_as_int) -> int { return 42; }
|
||||
@@ -740,7 +743,8 @@ TEST(core_test, format_to) {
|
||||
|
||||
TEST(core_test, format_as) {
|
||||
EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_int()), "42");
|
||||
EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_string()), "foo");
|
||||
// EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_string_view()), "foo");
|
||||
// EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_string()), "foo");
|
||||
EXPECT_EQ(fmt::format("{}", test::struct_as_int()), "42");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user