Simplify API

This commit is contained in:
Victor Zverovich
2017-02-05 06:54:03 -08:00
parent 624c58682d
commit a13b96ed88
10 changed files with 28 additions and 33 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ class CustomPrintfArgFormatter : public PrintfArgFormatter<char> {
}
};
std::string custom_vformat(fmt::CStringRef format_str, fmt::format_args args) {
std::string custom_vformat(fmt::CStringRef format_str, fmt::args args) {
fmt::MemoryWriter writer;
// Pass custom argument formatter as a template arg to vformat.
fmt::vwrite<CustomArgFormatter>(writer, format_str, args);
+1 -2
View File
@@ -55,9 +55,8 @@ struct ValueExtractor {
};
TEST(FormatTest, ArgConverter) {
using fmt::format_arg;
fmt::LongLong value = std::numeric_limits<fmt::LongLong>::max();
format_arg arg = fmt::internal::make_arg<fmt::context>(value);
auto arg = fmt::internal::make_arg<fmt::context>(value);
visit(fmt::internal::ArgConverter<
fmt::LongLong, fmt::context>(arg, 'd'), arg);
EXPECT_EQ(value, visit(ValueExtractor<fmt::LongLong>(), arg));
+2 -2
View File
@@ -1566,7 +1566,7 @@ TEST(StrTest, Convert) {
EXPECT_EQ("2012-12-9", s);
}
std::string vformat_message(int id, const char *format, fmt::format_args args) {
std::string vformat_message(int id, const char *format, fmt::args args) {
MemoryWriter w;
w.format("[{}] ", id);
w.vformat(format, args);
@@ -1656,7 +1656,7 @@ class MockArgFormatter : public fmt::internal::ArgFormatterBase<char> {
void operator()(fmt::internal::CustomValue<char>) {}
};
void custom_vformat(fmt::CStringRef format_str, fmt::format_args args) {
void custom_vformat(fmt::CStringRef format_str, fmt::args args) {
fmt::MemoryWriter writer;
fmt::vwrite<MockArgFormatter>(writer, format_str, args);
}
+1 -1
View File
@@ -65,7 +65,7 @@ struct TestArgFormatter : fmt::ArgFormatter<char> {
TEST(OStreamTest, CustomArg) {
fmt::MemoryWriter writer;
fmt::context ctx("}", fmt::format_args());
fmt::context ctx("}", fmt::args());
fmt::format_specs spec;
TestArgFormatter af(writer, ctx, spec);
visit(af, fmt::internal::make_arg<fmt::context>(TestEnum()));
+3 -4
View File
@@ -53,7 +53,6 @@
#undef max
using fmt::basic_arg;
using fmt::format_arg;
using fmt::buffer;
using fmt::StringRef;
using fmt::internal::MemoryBuffer;
@@ -408,7 +407,7 @@ TEST(UtilTest, Increment) {
}
TEST(UtilTest, FormatArgs) {
fmt::format_args args;
fmt::args args;
EXPECT_FALSE(args[1]);
}
@@ -570,7 +569,7 @@ TEST(UtilTest, CustomArg) {
testing::Invoke([&](fmt::internal::CustomValue<char> custom) {
EXPECT_EQ(&test, custom.value);
fmt::MemoryWriter w;
fmt::context ctx("}", fmt::format_args());
fmt::context ctx("}", fmt::args());
custom.format(w, &test, &ctx);
EXPECT_EQ("test", w.str());
return Visitor::Result();
@@ -582,7 +581,7 @@ TEST(ArgVisitorTest, VisitInvalidArg) {
typedef MockVisitor<fmt::monostate> Visitor;
testing::StrictMock<Visitor> visitor;
EXPECT_CALL(visitor, visit(_));
format_arg arg;
fmt::basic_arg<fmt::context> arg;
visit(visitor, arg);
}