mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-25 19:50:05 +00:00
Fix build on gcc 4.4
This commit is contained in:
parent
9d0c9c4bb1
commit
20c708bf6d
@ -189,7 +189,7 @@ enum class color : uint32_t {
|
||||
white = 0xFFFFFF, // rgb(255,255,255)
|
||||
white_smoke = 0xF5F5F5, // rgb(245,245,245)
|
||||
yellow = 0xFFFF00, // rgb(255,255,0)
|
||||
yellow_green = 0x9ACD32, // rgb(154,205,50)
|
||||
yellow_green = 0x9ACD32 // rgb(154,205,50)
|
||||
}; // enum class color
|
||||
|
||||
// rgb is a struct for red, green and blue colors.
|
||||
|
@ -91,8 +91,10 @@
|
||||
|
||||
#if FMT_HAS_FEATURE(cxx_explicit_conversions) || \
|
||||
FMT_GCC_VERSION >= 405 || FMT_MSC_VER >= 1800
|
||||
# define FMT_USE_EXPLICIT 1
|
||||
# define FMT_EXPLICIT explicit
|
||||
#else
|
||||
# define FMT_USE_EXPLICIT 0
|
||||
# define FMT_EXPLICIT
|
||||
#endif
|
||||
|
||||
@ -658,7 +660,12 @@ FMT_MAKE_VALUE_SAME(long_long_type, long long)
|
||||
FMT_MAKE_VALUE_SAME(ulong_long_type, unsigned long long)
|
||||
FMT_MAKE_VALUE(int_type, signed char, int)
|
||||
FMT_MAKE_VALUE(uint_type, unsigned char, unsigned)
|
||||
FMT_MAKE_VALUE(char_type, typename C::char_type, int)
|
||||
|
||||
// This doesn't use FMT_MAKE_VALUE because of ambiguity in gcc 4.4.
|
||||
template <typename C, typename Char>
|
||||
FMT_CONSTEXPR typename std::enable_if<
|
||||
std::is_same<typename C::char_type, Char>::value,
|
||||
init<C, int, char_type>>::type make_value(Char val) { return val; }
|
||||
|
||||
template <typename C>
|
||||
FMT_CONSTEXPR typename std::enable_if<
|
||||
@ -718,7 +725,7 @@ inline typename std::enable_if<
|
||||
|
||||
template <typename C, typename T, typename Char = typename C::char_type>
|
||||
inline typename std::enable_if<
|
||||
!convert_to_int<T, Char>::value &&
|
||||
!convert_to_int<T, Char>::value && !std::is_same<T, Char>::value &&
|
||||
!std::is_convertible<T, basic_string_view<Char>>::value &&
|
||||
!internal::is_constructible<basic_string_view<Char>, T>::value &&
|
||||
!internal::has_to_string_view<T>::value,
|
||||
|
@ -1725,7 +1725,7 @@ FMT_CONSTEXPR void set_dynamic_spec(
|
||||
T &value, basic_format_arg<Context> arg, ErrorHandler eh) {
|
||||
unsigned long long big_value =
|
||||
visit_format_arg(Handler<ErrorHandler>(eh), arg);
|
||||
if (big_value > (std::numeric_limits<int>::max)())
|
||||
if (big_value > to_unsigned((std::numeric_limits<int>::max)()))
|
||||
eh.on_error("number is too big");
|
||||
value = static_cast<T>(big_value);
|
||||
}
|
||||
@ -2111,7 +2111,7 @@ FMT_CONSTEXPR void parse_format_string(
|
||||
++p;
|
||||
if (p == end)
|
||||
return handler.on_error("invalid format string");
|
||||
if (*p == '}') {
|
||||
if (static_cast<char>(*p) == '}') {
|
||||
handler.on_arg_id();
|
||||
handler.on_replacement_field(p);
|
||||
} else if (*p == '{') {
|
||||
|
@ -65,6 +65,7 @@ struct formatter<test_struct, Char> {
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 470
|
||||
TEST(BufferTest, Noncopyable) {
|
||||
EXPECT_FALSE(std::is_copy_constructible<basic_buffer<char> >::value);
|
||||
#if !FMT_MSC_VER
|
||||
@ -80,11 +81,12 @@ TEST(BufferTest, Nonmoveable) {
|
||||
EXPECT_FALSE(std::is_move_assignable<basic_buffer<char> >::value);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// A test buffer with a dummy grow method.
|
||||
template <typename T>
|
||||
struct test_buffer : basic_buffer<T> {
|
||||
void grow(std::size_t capacity) { this->set(nullptr, capacity); }
|
||||
void grow(std::size_t capacity) { this->set(FMT_NULL, capacity); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@ -104,7 +106,7 @@ struct mock_buffer : basic_buffer<T> {
|
||||
TEST(BufferTest, Ctor) {
|
||||
{
|
||||
mock_buffer<int> buffer;
|
||||
EXPECT_EQ(nullptr, &buffer[0]);
|
||||
EXPECT_EQ(FMT_NULL, &buffer[0]);
|
||||
EXPECT_EQ(static_cast<size_t>(0), buffer.size());
|
||||
EXPECT_EQ(static_cast<size_t>(0), buffer.capacity());
|
||||
}
|
||||
@ -219,7 +221,7 @@ struct custom_context {
|
||||
|
||||
const char *format(const T &, custom_context& ctx) {
|
||||
ctx.called = true;
|
||||
return nullptr;
|
||||
return FMT_NULL;
|
||||
}
|
||||
};
|
||||
};
|
||||
@ -365,8 +367,8 @@ TEST(ArgTest, WStringArg) {
|
||||
}
|
||||
|
||||
TEST(ArgTest, PointerArg) {
|
||||
void *p = nullptr;
|
||||
const void *cp = nullptr;
|
||||
void *p = FMT_NULL;
|
||||
const void *cp = FMT_NULL;
|
||||
CHECK_ARG_(char, cp, p);
|
||||
CHECK_ARG_(wchar_t, cp, p);
|
||||
CHECK_ARG(cp, );
|
||||
@ -377,7 +379,7 @@ struct check_custom {
|
||||
fmt::basic_format_arg<fmt::format_context>::handle h) const {
|
||||
struct test_buffer : fmt::internal::basic_buffer<char> {
|
||||
char data[10];
|
||||
test_buffer() : basic_buffer(data, 0, 10) {}
|
||||
test_buffer() : fmt::internal::basic_buffer<char>(data, 0, 10) {}
|
||||
void grow(std::size_t) {}
|
||||
} buffer;
|
||||
fmt::internal::basic_buffer<char> &base = buffer;
|
||||
|
@ -136,9 +136,9 @@ TEST(FormatTest, FormatNegativeNaN) {
|
||||
}
|
||||
|
||||
TEST(FormatTest, StrError) {
|
||||
char *message = nullptr;
|
||||
char *message = FMT_NULL;
|
||||
char buffer[BUFFER_SIZE];
|
||||
EXPECT_ASSERT(fmt::safe_strerror(EDOM, message = nullptr, 0),
|
||||
EXPECT_ASSERT(fmt::safe_strerror(EDOM, message = FMT_NULL, 0),
|
||||
"invalid buffer");
|
||||
EXPECT_ASSERT(fmt::safe_strerror(EDOM, message = buffer, 0),
|
||||
"invalid buffer");
|
||||
|
@ -212,7 +212,7 @@ TEST(AllocatorTest, allocator_ref) {
|
||||
test_allocator_ref ref2(ref);
|
||||
check_forwarding(alloc, ref2);
|
||||
test_allocator_ref ref3;
|
||||
EXPECT_EQ(nullptr, ref3.get());
|
||||
EXPECT_EQ(FMT_NULL, ref3.get());
|
||||
ref3 = ref;
|
||||
check_forwarding(alloc, ref3);
|
||||
}
|
||||
@ -228,7 +228,7 @@ static void check_move_buffer(const char *str,
|
||||
EXPECT_EQ(str, std::string(&buffer2[0], buffer2.size()));
|
||||
EXPECT_EQ(5u, buffer2.capacity());
|
||||
// Move should transfer allocator.
|
||||
EXPECT_EQ(nullptr, buffer.get_allocator().get());
|
||||
EXPECT_EQ(FMT_NULL, buffer.get_allocator().get());
|
||||
EXPECT_EQ(alloc, buffer2.get_allocator().get());
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ TEST(MemoryBufferTest, Grow) {
|
||||
TEST(MemoryBufferTest, Allocator) {
|
||||
typedef allocator_ref< mock_allocator<char> > TestAllocator;
|
||||
basic_memory_buffer<char, 10, TestAllocator> buffer;
|
||||
EXPECT_EQ(nullptr, buffer.get_allocator().get());
|
||||
EXPECT_EQ(FMT_NULL, buffer.get_allocator().get());
|
||||
StrictMock< mock_allocator<char> > alloc;
|
||||
char mem;
|
||||
{
|
||||
@ -453,7 +453,7 @@ TEST(UtilTest, FormatSystemError) {
|
||||
fmt::print("warning: std::allocator allocates {} chars", max_size);
|
||||
return;
|
||||
}
|
||||
fmt::format_system_error(message, EDOM, fmt::string_view(nullptr, max_size));
|
||||
fmt::format_system_error(message, EDOM, fmt::string_view(FMT_NULL, max_size));
|
||||
EXPECT_EQ(fmt::format("error {}", EDOM), to_string(message));
|
||||
}
|
||||
|
||||
@ -1489,7 +1489,7 @@ TEST(FormatterTest, FormatCString) {
|
||||
EXPECT_EQ("test", format("{0:s}", "test"));
|
||||
char nonconst[] = "nonconst";
|
||||
EXPECT_EQ("nonconst", format("{0}", nonconst));
|
||||
EXPECT_THROW_MSG(format("{0}", static_cast<const char*>(nullptr)),
|
||||
EXPECT_THROW_MSG(format("{0}", static_cast<const char*>(FMT_NULL)),
|
||||
format_error, "string pointer is null");
|
||||
}
|
||||
|
||||
@ -1511,7 +1511,7 @@ TEST(FormatterTest, FormatUCharString) {
|
||||
|
||||
TEST(FormatterTest, FormatPointer) {
|
||||
check_unknown_types(reinterpret_cast<void*>(0x1234), "p", "pointer");
|
||||
EXPECT_EQ("0x0", format("{0}", static_cast<void*>(nullptr)));
|
||||
EXPECT_EQ("0x0", format("{0}", static_cast<void*>(FMT_NULL)));
|
||||
EXPECT_EQ("0x1234", format("{0}", reinterpret_cast<void*>(0x1234)));
|
||||
EXPECT_EQ("0x1234", format("{0:p}", reinterpret_cast<void*>(0x1234)));
|
||||
EXPECT_EQ("0x" + std::string(sizeof(void*) * CHAR_BIT / 4, 'f'),
|
||||
@ -1546,7 +1546,7 @@ TEST(FormatterTest, FormatImplicitlyConvertibleToStringView) {
|
||||
}
|
||||
|
||||
// std::is_constructible is broken in MSVC until version 2015.
|
||||
#if !FMT_MSC_VER || FMT_MSC_VER >= 1900
|
||||
#if FMT_USE_EXPLICIT && (!FMT_MSC_VER || FMT_MSC_VER >= 1900)
|
||||
struct explicitly_convertible_to_string_view {
|
||||
explicit operator fmt::string_view() const { return "foo"; }
|
||||
};
|
||||
@ -1652,7 +1652,7 @@ TEST(FormatterTest, FormatExamples) {
|
||||
FILE *ftest = safe_fopen(filename, "r");
|
||||
if (ftest) fclose(ftest);
|
||||
int error_code = errno;
|
||||
EXPECT_TRUE(ftest == nullptr);
|
||||
EXPECT_TRUE(ftest == FMT_NULL);
|
||||
EXPECT_SYSTEM_ERROR({
|
||||
FILE *f = safe_fopen(filename, "r");
|
||||
if (!f)
|
||||
@ -1769,7 +1769,7 @@ TEST(FormatTest, Variadic) {
|
||||
}
|
||||
|
||||
TEST(FormatTest, Dynamic) {
|
||||
using ctx = fmt::format_context;
|
||||
typedef fmt::format_context ctx;
|
||||
std::vector<fmt::basic_format_arg<ctx>> args;
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>(42));
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>("abc1"));
|
||||
@ -2321,7 +2321,7 @@ FMT_CONSTEXPR bool equal(const char *s1, const char *s2) {
|
||||
|
||||
template <typename... Args>
|
||||
FMT_CONSTEXPR bool test_error(const char *fmt, const char *expected_error) {
|
||||
const char *actual_error = nullptr;
|
||||
const char *actual_error = FMT_NULL;
|
||||
fmt::internal::check_format_string<char, test_error_handler, Args...>(
|
||||
string_view(fmt, len(fmt)), test_error_handler(actual_error));
|
||||
return equal(actual_error, expected_error);
|
||||
@ -2333,7 +2333,7 @@ FMT_CONSTEXPR bool test_error(const char *fmt, const char *expected_error) {
|
||||
static_assert(test_error<__VA_ARGS__>(fmt, error), "")
|
||||
|
||||
TEST(FormatTest, FormatStringErrors) {
|
||||
EXPECT_ERROR_NOARGS("foo", nullptr);
|
||||
EXPECT_ERROR_NOARGS("foo", FMT_NULL);
|
||||
EXPECT_ERROR_NOARGS("}", "unmatched '}' in format string");
|
||||
EXPECT_ERROR("{0:s", "unknown format specifier", Date);
|
||||
#ifndef _MSC_VER
|
||||
|
@ -340,10 +340,10 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
|
||||
// Put a character in a file buffer.
|
||||
EXPECT_EQ('x', fputc('x', f.get()));
|
||||
FMT_POSIX(close(write_fd));
|
||||
scoped_ptr<OutputRedirect> redir{nullptr};
|
||||
scoped_ptr<OutputRedirect> redir{FMT_NULL};
|
||||
EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())),
|
||||
EBADF, "cannot flush stream");
|
||||
redir.reset(nullptr);
|
||||
redir.reset(FMT_NULL);
|
||||
write_copy.dup2(write_fd); // "undo" close or dtor will fail
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ TEST(OutputRedirectTest, DupErrorInCtor) {
|
||||
int fd = (f.fileno)();
|
||||
file copy = file::dup(fd);
|
||||
FMT_POSIX(close(fd));
|
||||
scoped_ptr<OutputRedirect> redir{nullptr};
|
||||
scoped_ptr<OutputRedirect> redir{FMT_NULL};
|
||||
EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())),
|
||||
EBADF, fmt::format("cannot duplicate file descriptor {}", fd));
|
||||
copy.dup2(fd); // "undo" close or dtor will fail
|
||||
@ -403,7 +403,7 @@ TEST(OutputRedirectTest, ErrorInDtor) {
|
||||
// output in EXPECT_STDERR and the second close will break output
|
||||
// redirection.
|
||||
FMT_POSIX(close(write_fd));
|
||||
SUPPRESS_ASSERT(redir.reset(nullptr));
|
||||
SUPPRESS_ASSERT(redir.reset(FMT_NULL));
|
||||
}, format_system_error(EBADF, "cannot flush stream"));
|
||||
write_copy.dup2(write_fd); // "undo" close or dtor of buffered_file will fail
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ std::string read(fmt::file &f, std::size_t count);
|
||||
template <typename Mock>
|
||||
struct ScopedMock : testing::StrictMock<Mock> {
|
||||
ScopedMock() { Mock::instance = this; }
|
||||
~ScopedMock() { Mock::instance = nullptr; }
|
||||
~ScopedMock() { Mock::instance = FMT_NULL; }
|
||||
};
|
||||
|
||||
#endif // FMT_GTEST_EXTRA_H_
|
||||
|
@ -28,13 +28,13 @@ class allocator_ref {
|
||||
|
||||
void move(allocator_ref &other) {
|
||||
alloc_ = other.alloc_;
|
||||
other.alloc_ = nullptr;
|
||||
other.alloc_ = FMT_NULL;
|
||||
}
|
||||
|
||||
public:
|
||||
typedef typename Allocator::value_type value_type;
|
||||
|
||||
explicit allocator_ref(Allocator *alloc = nullptr) : alloc_(alloc) {}
|
||||
explicit allocator_ref(Allocator *alloc = FMT_NULL) : alloc_(alloc) {}
|
||||
|
||||
allocator_ref(const allocator_ref &other) : alloc_(other.alloc_) {}
|
||||
allocator_ref(allocator_ref &&other) { move(other); }
|
||||
|
@ -146,7 +146,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
|
||||
} os(streambuf);
|
||||
|
||||
testing::InSequence sequence;
|
||||
const char *data = nullptr;
|
||||
const char *data = FMT_NULL;
|
||||
std::size_t size = max_size;
|
||||
do {
|
||||
typedef std::make_unsigned<std::streamsize>::type ustreamsize;
|
||||
|
@ -133,7 +133,7 @@ int test::dup2(int fildes, int fildes2) {
|
||||
}
|
||||
|
||||
FILE *test::fdopen(int fildes, const char *mode) {
|
||||
EMULATE_EINTR(fdopen, nullptr);
|
||||
EMULATE_EINTR(fdopen, FMT_NULL);
|
||||
return ::FMT_POSIX(fdopen(fildes, mode));
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ int test::pipe(int *pfds, unsigned psize, int textmode) {
|
||||
#endif
|
||||
|
||||
FILE *test::fopen(const char *filename, const char *mode) {
|
||||
EMULATE_EINTR(fopen, nullptr);
|
||||
EMULATE_EINTR(fopen, FMT_NULL);
|
||||
return ::fopen(filename, mode);
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ TEST(UtilTest, GetPageSize) {
|
||||
|
||||
TEST(FileTest, OpenRetry) {
|
||||
write_file("test", "there must be something here");
|
||||
scoped_ptr<file> f{nullptr};
|
||||
scoped_ptr<file> f{FMT_NULL};
|
||||
EXPECT_RETRY(f.reset(new file("test", file::RDONLY)),
|
||||
open, "cannot open file test");
|
||||
#ifndef _WIN32
|
||||
@ -232,7 +232,7 @@ TEST(FileTest, CloseNoRetryInDtor) {
|
||||
int saved_close_count = 0;
|
||||
EXPECT_WRITE(stderr, {
|
||||
close_count = 1;
|
||||
f.reset(nullptr);
|
||||
f.reset(FMT_NULL);
|
||||
saved_close_count = close_count;
|
||||
close_count = 0;
|
||||
}, format_system_error(EINTR, "cannot close file") + "\n");
|
||||
@ -385,7 +385,7 @@ TEST(FileTest, FdopenNoRetry) {
|
||||
|
||||
TEST(BufferedFileTest, OpenRetry) {
|
||||
write_file("test", "there must be something here");
|
||||
scoped_ptr<buffered_file> f{nullptr};
|
||||
scoped_ptr<buffered_file> f{FMT_NULL};
|
||||
EXPECT_RETRY(f.reset(new buffered_file("test", "r")),
|
||||
fopen, "cannot open file test");
|
||||
#ifndef _WIN32
|
||||
@ -402,7 +402,7 @@ TEST(BufferedFileTest, CloseNoRetryInDtor) {
|
||||
int saved_fclose_count = 0;
|
||||
EXPECT_WRITE(stderr, {
|
||||
fclose_count = 1;
|
||||
f.reset(nullptr);
|
||||
f.reset(FMT_NULL);
|
||||
saved_fclose_count = fclose_count;
|
||||
fclose_count = 0;
|
||||
}, format_system_error(EINTR, "cannot close file") + "\n");
|
||||
@ -440,7 +440,7 @@ TEST(ScopedMock, Scope) {
|
||||
TestMock © = mock;
|
||||
static_cast<void>(copy);
|
||||
}
|
||||
EXPECT_EQ(nullptr, TestMock::instance);
|
||||
EXPECT_EQ(FMT_NULL, TestMock::instance);
|
||||
}
|
||||
|
||||
#ifdef FMT_LOCALE
|
||||
@ -515,7 +515,7 @@ TEST(LocaleTest, Locale) {
|
||||
#endif
|
||||
ScopedMock<LocaleMock> mock;
|
||||
LocaleType impl = reinterpret_cast<LocaleType>(42);
|
||||
EXPECT_CALL(mock, newlocale(LC_NUMERIC_MASK, StrEq("C"), nullptr))
|
||||
EXPECT_CALL(mock, newlocale(LC_NUMERIC_MASK, StrEq("C"), FMT_NULL))
|
||||
.WillOnce(Return(impl));
|
||||
EXPECT_CALL(mock, freelocale(impl));
|
||||
fmt::Locale locale;
|
||||
|
@ -59,26 +59,26 @@ static void write(file &f, fmt::string_view s) {
|
||||
|
||||
TEST(BufferedFileTest, DefaultCtor) {
|
||||
buffered_file f;
|
||||
EXPECT_TRUE(f.get() == nullptr);
|
||||
EXPECT_TRUE(f.get() == FMT_NULL);
|
||||
}
|
||||
|
||||
TEST(BufferedFileTest, MoveCtor) {
|
||||
buffered_file bf = open_buffered_file();
|
||||
FILE *fp = bf.get();
|
||||
EXPECT_TRUE(fp != nullptr);
|
||||
EXPECT_TRUE(fp != FMT_NULL);
|
||||
buffered_file bf2(std::move(bf));
|
||||
EXPECT_EQ(fp, bf2.get());
|
||||
EXPECT_TRUE(bf.get() == nullptr);
|
||||
EXPECT_TRUE(bf.get() == FMT_NULL);
|
||||
}
|
||||
|
||||
TEST(BufferedFileTest, MoveAssignment) {
|
||||
buffered_file bf = open_buffered_file();
|
||||
FILE *fp = bf.get();
|
||||
EXPECT_TRUE(fp != nullptr);
|
||||
EXPECT_TRUE(fp != FMT_NULL);
|
||||
buffered_file bf2;
|
||||
bf2 = std::move(bf);
|
||||
EXPECT_EQ(fp, bf2.get());
|
||||
EXPECT_TRUE(bf.get() == nullptr);
|
||||
EXPECT_TRUE(bf.get() == FMT_NULL);
|
||||
}
|
||||
|
||||
TEST(BufferedFileTest, MoveAssignmentClosesFile) {
|
||||
@ -90,13 +90,13 @@ TEST(BufferedFileTest, MoveAssignmentClosesFile) {
|
||||
}
|
||||
|
||||
TEST(BufferedFileTest, MoveFromTemporaryInCtor) {
|
||||
FILE *fp = nullptr;
|
||||
FILE *fp = FMT_NULL;
|
||||
buffered_file f(open_buffered_file(&fp));
|
||||
EXPECT_EQ(fp, f.get());
|
||||
}
|
||||
|
||||
TEST(BufferedFileTest, MoveFromTemporaryInAssignment) {
|
||||
FILE *fp = nullptr;
|
||||
FILE *fp = FMT_NULL;
|
||||
buffered_file f;
|
||||
f = open_buffered_file(&fp);
|
||||
EXPECT_EQ(fp, f.get());
|
||||
@ -126,7 +126,7 @@ TEST(BufferedFileTest, CloseErrorInDtor) {
|
||||
// output in EXPECT_STDERR and the second close will break output
|
||||
// redirection.
|
||||
FMT_POSIX(close(f->fileno()));
|
||||
SUPPRESS_ASSERT(f.reset(nullptr));
|
||||
SUPPRESS_ASSERT(f.reset(FMT_NULL));
|
||||
}, format_system_error(EBADF, "cannot close file") + "\n");
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ TEST(BufferedFileTest, Close) {
|
||||
buffered_file f = open_buffered_file();
|
||||
int fd = f.fileno();
|
||||
f.close();
|
||||
EXPECT_TRUE(f.get() == nullptr);
|
||||
EXPECT_TRUE(f.get() == FMT_NULL);
|
||||
EXPECT_TRUE(isclosed(fd));
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ TEST(BufferedFileTest, CloseError) {
|
||||
buffered_file f = open_buffered_file();
|
||||
FMT_POSIX(close(f.fileno()));
|
||||
EXPECT_SYSTEM_ERROR_NOASSERT(f.close(), EBADF, "cannot close file");
|
||||
EXPECT_TRUE(f.get() == nullptr);
|
||||
EXPECT_TRUE(f.get() == FMT_NULL);
|
||||
}
|
||||
|
||||
TEST(BufferedFileTest, Fileno) {
|
||||
@ -253,7 +253,7 @@ TEST(FileTest, CloseErrorInDtor) {
|
||||
// output in EXPECT_STDERR and the second close will break output
|
||||
// redirection.
|
||||
FMT_POSIX(close(f->descriptor()));
|
||||
SUPPRESS_ASSERT(f.reset(nullptr));
|
||||
SUPPRESS_ASSERT(f.reset(FMT_NULL));
|
||||
}, format_system_error(EBADF, "cannot close file") + "\n");
|
||||
}
|
||||
|
||||
|
@ -426,11 +426,11 @@ TEST(PrintfTest, Char) {
|
||||
|
||||
TEST(PrintfTest, String) {
|
||||
EXPECT_PRINTF("abc", "%s", "abc");
|
||||
const char *null_str = nullptr;
|
||||
const char *null_str = FMT_NULL;
|
||||
EXPECT_PRINTF("(null)", "%s", null_str);
|
||||
EXPECT_PRINTF(" (null)", "%10s", null_str);
|
||||
EXPECT_PRINTF(L"abc", L"%s", L"abc");
|
||||
const wchar_t *null_wstr = nullptr;
|
||||
const wchar_t *null_wstr = FMT_NULL;
|
||||
EXPECT_PRINTF(L"(null)", L"%s", null_wstr);
|
||||
EXPECT_PRINTF(L" (null)", L"%10s", null_wstr);
|
||||
}
|
||||
@ -439,22 +439,22 @@ TEST(PrintfTest, Pointer) {
|
||||
int n;
|
||||
void *p = &n;
|
||||
EXPECT_PRINTF(fmt::format("{}", p), "%p", p);
|
||||
p = nullptr;
|
||||
p = FMT_NULL;
|
||||
EXPECT_PRINTF("(nil)", "%p", p);
|
||||
EXPECT_PRINTF(" (nil)", "%10p", p);
|
||||
const char *s = "test";
|
||||
EXPECT_PRINTF(fmt::format("{:p}", s), "%p", s);
|
||||
const char *null_str = nullptr;
|
||||
const char *null_str = FMT_NULL;
|
||||
EXPECT_PRINTF("(nil)", "%p", null_str);
|
||||
|
||||
p = &n;
|
||||
EXPECT_PRINTF(fmt::format(L"{}", p), L"%p", p);
|
||||
p = nullptr;
|
||||
p = FMT_NULL;
|
||||
EXPECT_PRINTF(L"(nil)", L"%p", p);
|
||||
EXPECT_PRINTF(L" (nil)", L"%10p", p);
|
||||
const wchar_t *w = L"test";
|
||||
EXPECT_PRINTF(fmt::format(L"{:p}", w), L"%p", w);
|
||||
const wchar_t *null_wstr = nullptr;
|
||||
const wchar_t *null_wstr = FMT_NULL;
|
||||
EXPECT_PRINTF(L"(nil)", L"%p", null_wstr);
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,11 @@
|
||||
// All Rights Reserved
|
||||
// {fmt} support for ranges, containers and types tuple interface.
|
||||
|
||||
#include "fmt/ranges.h"
|
||||
|
||||
/// Check if 'if constexpr' is supported.
|
||||
#if (__cplusplus > 201402L) || \
|
||||
(defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910)
|
||||
|
||||
#include "fmt/ranges.h"
|
||||
#include "gtest.h"
|
||||
|
||||
#include <vector>
|
||||
|
@ -26,7 +26,7 @@ TEST(TimeTest, GrowBuffer) {
|
||||
for (int i = 0; i < 30; ++i)
|
||||
s += "%c";
|
||||
s += "}\n";
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::time_t t = std::time(FMT_NULL);
|
||||
fmt::format(s, *std::localtime(&t));
|
||||
}
|
||||
|
||||
@ -47,13 +47,13 @@ static bool EqualTime(const std::tm &lhs, const std::tm &rhs) {
|
||||
}
|
||||
|
||||
TEST(TimeTest, LocalTime) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::time_t t = std::time(FMT_NULL);
|
||||
std::tm tm = *std::localtime(&t);
|
||||
EXPECT_TRUE(EqualTime(tm, fmt::localtime(t)));
|
||||
}
|
||||
|
||||
TEST(TimeTest, GMTime) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::time_t t = std::time(FMT_NULL);
|
||||
std::tm tm = *std::gmtime(&t);
|
||||
EXPECT_TRUE(EqualTime(tm, fmt::gmtime(t)));
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ std::string get_system_error(int error_code);
|
||||
extern const char *const FILE_CONTENT;
|
||||
|
||||
// Opens a buffered file for reading.
|
||||
fmt::buffered_file open_buffered_file(FILE **fp = nullptr);
|
||||
fmt::buffered_file open_buffered_file(FILE **fp = FMT_NULL);
|
||||
|
||||
inline FILE *safe_fopen(const char *filename, const char *mode) {
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
|
Loading…
Reference in New Issue
Block a user