mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-29 18:27:40 +02:00
Minor cleanup
This commit is contained in:
@ -413,37 +413,31 @@ TEST(std_test, format_shared_ptr) {
|
||||
|
||||
TEST(std_test, format_reference_wrapper) {
|
||||
int num = 35;
|
||||
EXPECT_EQ("35", fmt::to_string(std::cref(num)));
|
||||
EXPECT_EQ("35", fmt::to_string(std::ref(num)));
|
||||
EXPECT_EQ("35", fmt::format("{}", std::cref(num)));
|
||||
EXPECT_EQ("35", fmt::format("{}", std::ref(num)));
|
||||
EXPECT_EQ(fmt::to_string(std::cref(num)), "35");
|
||||
EXPECT_EQ(fmt::to_string(std::ref(num)), "35");
|
||||
EXPECT_EQ(fmt::format("{}", std::cref(num)), "35");
|
||||
EXPECT_EQ(fmt::format("{}", std::ref(num)), "35");
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/fmtlib/fmt/issues/4424
|
||||
struct type_with_format_as {
|
||||
int x;
|
||||
};
|
||||
|
||||
int format_as(const type_with_format_as& t) { return t.x; }
|
||||
// Regression test for https://github.com/fmtlib/fmt/issues/4424.
|
||||
struct type_with_format_as {};
|
||||
int format_as(type_with_format_as) { return 20; }
|
||||
|
||||
TEST(std_test, format_reference_wrapper_with_format_as) {
|
||||
type_with_format_as t{20};
|
||||
EXPECT_EQ("20", fmt::to_string(std::cref(t)));
|
||||
EXPECT_EQ("20", fmt::to_string(std::ref(t)));
|
||||
EXPECT_EQ("20", fmt::format("{}", std::cref(t)));
|
||||
EXPECT_EQ("20", fmt::format("{}", std::ref(t)));
|
||||
type_with_format_as t;
|
||||
EXPECT_EQ(fmt::to_string(std::cref(t)), "20");
|
||||
EXPECT_EQ(fmt::to_string(std::ref(t)), "20");
|
||||
EXPECT_EQ(fmt::format("{}", std::cref(t)), "20");
|
||||
EXPECT_EQ(fmt::format("{}", std::ref(t)), "20");
|
||||
}
|
||||
|
||||
struct type_with_format_as_string {
|
||||
std::string str;
|
||||
};
|
||||
|
||||
std::string format_as(const type_with_format_as_string& t) { return t.str; }
|
||||
struct type_with_format_as_string {};
|
||||
std::string format_as(type_with_format_as_string) { return "foo"; }
|
||||
|
||||
TEST(std_test, format_reference_wrapper_with_format_as_string) {
|
||||
type_with_format_as_string t{"foo"};
|
||||
EXPECT_EQ("foo", fmt::to_string(std::cref(t)));
|
||||
EXPECT_EQ("foo", fmt::to_string(std::ref(t)));
|
||||
EXPECT_EQ("foo", fmt::format("{}", std::cref(t)));
|
||||
EXPECT_EQ("foo", fmt::format("{}", std::ref(t)));
|
||||
type_with_format_as_string t;
|
||||
EXPECT_EQ(fmt::to_string(std::cref(t)), "foo");
|
||||
EXPECT_EQ(fmt::to_string(std::ref(t)), "foo");
|
||||
EXPECT_EQ(fmt::format("{}", std::cref(t)), "foo");
|
||||
EXPECT_EQ(fmt::format("{}", std::ref(t)), "foo");
|
||||
}
|
||||
|
Reference in New Issue
Block a user