Parameterize Value on context

This commit is contained in:
Victor Zverovich
2016-12-29 18:07:05 -08:00
parent a4d6cb32d1
commit 42a319074c
2 changed files with 15 additions and 15 deletions

View File

@@ -412,19 +412,20 @@ TEST(UtilTest, FormatArgs) {
EXPECT_FALSE(args[1]);
}
struct CustomFormatter {
struct CustomContext {
typedef char char_type;
bool called;
};
void format_value(fmt::Writer &, const Test &, CustomFormatter &ctx) {
void format_value(fmt::Writer &, const Test &, CustomContext &ctx) {
ctx.called = true;
}
TEST(UtilTest, MakeValueWithCustomFormatter) {
::Test t;
fmt::internal::Value<char> arg = fmt::internal::MakeValue<CustomFormatter>(t);
CustomFormatter ctx = {false};
fmt::internal::Value<CustomContext> arg =
fmt::internal::MakeValue<CustomContext>(t);
CustomContext ctx = {false};
fmt::MemoryWriter w;
arg.custom.format(w, &t, &ctx);
EXPECT_TRUE(ctx.called);