Fix compilation errors on gcc 4.4
This commit is contained in:
@@ -18,7 +18,7 @@ class CustomArgFormatter :
|
||||
public fmt::arg_formatter<fmt::back_insert_range<fmt::internal::buffer>> {
|
||||
public:
|
||||
typedef fmt::back_insert_range<fmt::internal::buffer> range;
|
||||
typedef decltype(std::declval<range>().begin()) iterator;
|
||||
typedef decltype(fmt::internal::declval<range>().begin()) iterator;
|
||||
typedef fmt::arg_formatter<range> base;
|
||||
|
||||
CustomArgFormatter(fmt::basic_context<iterator, char> &ctx,
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#undef max
|
||||
|
||||
template <typename T>
|
||||
struct ValueExtractor {
|
||||
struct ValueExtractor: fmt::internal::function<T> {
|
||||
T operator()(T value) {
|
||||
return value;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ struct ValueExtractor {
|
||||
TEST(FormatTest, ArgConverter) {
|
||||
long long value = std::numeric_limits<long long>::max();
|
||||
auto arg = fmt::internal::make_arg<fmt::context>(value);
|
||||
visit(fmt::internal::ArgConverter<long long, fmt::context>(arg, 'd'), arg);
|
||||
visit(fmt::internal::arg_converter<long long, fmt::context>(arg, 'd'), arg);
|
||||
EXPECT_EQ(value, visit(ValueExtractor<long long>(), arg));
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -1205,7 +1205,9 @@ TEST(FormatterTest, FormatPointer) {
|
||||
EXPECT_EQ("0x" + std::string(sizeof(void*) * CHAR_BIT / 4, 'f'),
|
||||
format("{0}", reinterpret_cast<void*>(~uintptr_t())));
|
||||
EXPECT_EQ("0x1234", format("{}", fmt::ptr(reinterpret_cast<int*>(0x1234))));
|
||||
EXPECT_EQ("0x0", format("{}", nullptr));
|
||||
#if FMT_USE_NULLPTR
|
||||
EXPECT_EQ("0x0", format("{}", FMT_NULL));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatString) {
|
||||
@@ -1450,7 +1452,7 @@ TEST(FormatTest, JoinArg) {
|
||||
EXPECT_EQ(L"(1, 2, 3)", format(L"({})", join(v1, v1 + 3, L", ")));
|
||||
EXPECT_EQ("1, 2, 3", format("{0:{1}}", join(v1, v1 + 3, ", "), 1));
|
||||
|
||||
#if FMT_HAS_GXX_CXX11
|
||||
#if FMT_USE_TRAILING_RETURN && (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 405)
|
||||
EXPECT_EQ("(1, 2, 3)", format("({})", join(v1, ", ")));
|
||||
EXPECT_EQ("(+01.20, +03.40)", format("({:+06.2f})", join(v2, ", ")));
|
||||
#endif
|
||||
@@ -1551,7 +1553,8 @@ TEST(FormatTest, FixedEnum) {
|
||||
|
||||
typedef fmt::back_insert_range<fmt::internal::buffer> buffer_range;
|
||||
|
||||
class mock_arg_formatter :
|
||||
class mock_arg_formatter:
|
||||
public fmt::internal::function<void>,
|
||||
public fmt::internal::arg_formatter_base<buffer_range> {
|
||||
private:
|
||||
MOCK_METHOD1(call, void (int value));
|
||||
@@ -1602,8 +1605,8 @@ template <>
|
||||
struct formatter<variant> : dynamic_formatter<> {
|
||||
auto format(variant value, context& ctx) -> decltype(ctx.begin()) {
|
||||
if (value.type == variant::INT)
|
||||
return dynamic_formatter::format(42, ctx);
|
||||
return dynamic_formatter::format("foo", ctx);
|
||||
return dynamic_formatter<>::format(42, ctx);
|
||||
return dynamic_formatter<>::format("foo", ctx);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+23
-19
@@ -478,12 +478,12 @@ bool operator==(custom_value<Char> lhs, custom_value<Char> rhs) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct MockVisitor {
|
||||
// Use a unique result type to make sure that there are no undesirable
|
||||
// conversions.
|
||||
struct Result {};
|
||||
// Use a unique result type to make sure that there are no undesirable
|
||||
// conversions.
|
||||
struct Result {};
|
||||
|
||||
template <typename T>
|
||||
struct MockVisitor: fmt::internal::function<Result> {
|
||||
MockVisitor() {
|
||||
ON_CALL(*this, visit(_)).WillByDefault(Return(Result()));
|
||||
}
|
||||
@@ -529,8 +529,9 @@ VISIT_TYPE(float, double);
|
||||
fmt::visit(visitor, make_arg<fmt::basic_context<iterator, Char>>(value)); \
|
||||
}
|
||||
|
||||
#define CHECK_ARG(value) { \
|
||||
typename VisitType<decltype(value)>::Type expected = value; \
|
||||
#define CHECK_ARG(value, typename_) { \
|
||||
typedef decltype(value) value_type; \
|
||||
typename_ VisitType<value_type>::Type expected = value; \
|
||||
CHECK_ARG_(char, expected, value) \
|
||||
CHECK_ARG_(wchar_t, expected, value) \
|
||||
}
|
||||
@@ -556,9 +557,9 @@ typename std::enable_if<std::is_floating_point<T>::value, T>::type
|
||||
}
|
||||
|
||||
TYPED_TEST(NumericArgTest, MakeAndVisit) {
|
||||
CHECK_ARG(test_value<TypeParam>());
|
||||
CHECK_ARG(std::numeric_limits<TypeParam>::min());
|
||||
CHECK_ARG(std::numeric_limits<TypeParam>::max());
|
||||
CHECK_ARG(test_value<TypeParam>(), typename);
|
||||
CHECK_ARG(std::numeric_limits<TypeParam>::min(), typename);
|
||||
CHECK_ARG(std::numeric_limits<TypeParam>::max(), typename);
|
||||
}
|
||||
|
||||
TEST(UtilTest, CharArg) {
|
||||
@@ -594,22 +595,25 @@ TEST(UtilTest, PointerArg) {
|
||||
const void *cp = 0;
|
||||
CHECK_ARG_(char, cp, p);
|
||||
CHECK_ARG_(wchar_t, cp, p);
|
||||
CHECK_ARG(cp);
|
||||
CHECK_ARG(cp, );
|
||||
}
|
||||
|
||||
TEST(UtilTest, CustomArg) {
|
||||
::Test test;
|
||||
typedef typename fmt::basic_arg<fmt::context>::handle handle;
|
||||
typedef MockVisitor<handle> visitor;
|
||||
testing::StrictMock<visitor> v;
|
||||
EXPECT_CALL(v, visit(_)).WillOnce(testing::Invoke([&](handle h) {
|
||||
struct check_custom {
|
||||
Result operator()(fmt::basic_arg<fmt::context>::handle h) const {
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::internal::basic_buffer<char> &base = buffer;
|
||||
fmt::context ctx(std::back_inserter(base), "", fmt::format_args());
|
||||
h.format(ctx);
|
||||
EXPECT_EQ("test", std::string(buffer.data(), buffer.size()));
|
||||
return visitor::Result();
|
||||
}));
|
||||
return Result();
|
||||
}
|
||||
};
|
||||
|
||||
TEST(UtilTest, CustomArg) {
|
||||
::Test test;
|
||||
typedef MockVisitor<fmt::basic_arg<fmt::context>::handle> visitor;
|
||||
testing::StrictMock<visitor> v;
|
||||
EXPECT_CALL(v, visit(_)).WillOnce(testing::Invoke(check_custom()));
|
||||
fmt::visit(v, make_arg<fmt::context>(test));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user