internal::MemoryBuffer -> basic_memory_buffer
This commit is contained in:
@@ -46,7 +46,7 @@ class CustomPrintfArgFormatter : public printf_arg_formatter<char> {
|
||||
};
|
||||
|
||||
std::string custom_vformat(fmt::CStringRef format_str, fmt::args args) {
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
// Pass custom argument formatter as a template arg to vwrite.
|
||||
fmt::vformat_to<CustomArgFormatter>(buffer, format_str, args);
|
||||
return std::string(buffer.data(), buffer.size());
|
||||
@@ -64,7 +64,7 @@ typedef fmt::printf_context<char, CustomPrintfArgFormatter>
|
||||
std::string custom_vsprintf(
|
||||
const char* format_str,
|
||||
fmt::basic_args<CustomPrintfFormatter> args) {
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
CustomPrintfFormatter formatter(format_str, args);
|
||||
formatter.format(buffer);
|
||||
return std::string(buffer.data(), buffer.size());
|
||||
|
||||
+14
-14
@@ -105,33 +105,33 @@ TEST(FormatTest, StrError) {
|
||||
TEST(FormatTest, FormatErrorCode) {
|
||||
std::string msg = "error 42", sep = ": ";
|
||||
{
|
||||
fmt::MemoryWriter w;
|
||||
w.write("garbage");
|
||||
fmt::format_error_code(w.buffer(), 42, "test");
|
||||
EXPECT_EQ("test: " + msg, w.str());
|
||||
fmt::memory_buffer buffer;
|
||||
format_to(buffer, "garbage");
|
||||
fmt::format_error_code(buffer, 42, "test");
|
||||
EXPECT_EQ("test: " + msg, to_string(buffer));
|
||||
}
|
||||
{
|
||||
fmt::MemoryWriter w;
|
||||
fmt::memory_buffer buffer;
|
||||
std::string prefix(
|
||||
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size() + 1, 'x');
|
||||
fmt::format_error_code(w.buffer(), 42, prefix);
|
||||
EXPECT_EQ(msg, w.str());
|
||||
fmt::format_error_code(buffer, 42, prefix);
|
||||
EXPECT_EQ(msg, to_string(buffer));
|
||||
}
|
||||
int codes[] = {42, -1};
|
||||
for (std::size_t i = 0, n = sizeof(codes) / sizeof(*codes); i < n; ++i) {
|
||||
// Test maximum buffer size.
|
||||
msg = fmt::format("error {}", codes[i]);
|
||||
fmt::MemoryWriter w;
|
||||
fmt::memory_buffer buffer;
|
||||
std::string prefix(
|
||||
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size(), 'x');
|
||||
fmt::format_error_code(w.buffer(), codes[i], prefix);
|
||||
EXPECT_EQ(prefix + sep + msg, w.str());
|
||||
fmt::format_error_code(buffer, codes[i], prefix);
|
||||
EXPECT_EQ(prefix + sep + msg, to_string(buffer));
|
||||
std::size_t size = fmt::internal::INLINE_BUFFER_SIZE;
|
||||
EXPECT_EQ(size, w.size());
|
||||
w.clear();
|
||||
EXPECT_EQ(size, buffer.size());
|
||||
buffer.clear();
|
||||
// Test with a message that doesn't fit into the buffer.
|
||||
prefix += 'x';
|
||||
fmt::format_error_code(w.buffer(), codes[i], prefix);
|
||||
EXPECT_EQ(msg, w.str());
|
||||
fmt::format_error_code(buffer, codes[i], prefix);
|
||||
EXPECT_EQ(msg, to_string(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
+25
-102
@@ -75,8 +75,8 @@ using fmt::format;
|
||||
using fmt::format_error;
|
||||
using fmt::string_view;
|
||||
using fmt::CStringRef;
|
||||
using fmt::MemoryWriter;
|
||||
using fmt::WMemoryWriter;
|
||||
using fmt::memory_buffer;
|
||||
using fmt::wmemory_buffer;
|
||||
using fmt::fill;
|
||||
using fmt::type;
|
||||
using fmt::width;
|
||||
@@ -109,7 +109,8 @@ void std_format(long double value, std::wstring &result) {
|
||||
// as writing it to std::basic_ostringstream<Char>.
|
||||
template <typename Char, typename T>
|
||||
::testing::AssertionResult check_write(const T &value, const char *type) {
|
||||
fmt::BasicMemoryWriter<Char> writer;
|
||||
fmt::basic_memory_buffer<Char> buffer;
|
||||
fmt::basic_writer<Char> writer(buffer);
|
||||
writer.write(value);
|
||||
std::basic_string<Char> actual = writer.str();
|
||||
std::basic_string<Char> expected;
|
||||
@@ -177,90 +178,16 @@ TEST(WriterTest, NotCopyAssignable) {
|
||||
#endif
|
||||
|
||||
TEST(WriterTest, Ctor) {
|
||||
MemoryWriter w;
|
||||
memory_buffer buf;
|
||||
fmt::basic_writer<char> w(buf);
|
||||
EXPECT_EQ(0u, w.size());
|
||||
EXPECT_STREQ("", w.c_str());
|
||||
EXPECT_EQ("", w.str());
|
||||
}
|
||||
|
||||
#if FMT_USE_RVALUE_REFERENCES
|
||||
|
||||
void check_move_writer(const std::string &str, MemoryWriter &w) {
|
||||
MemoryWriter w2(std::move(w));
|
||||
// Move shouldn't destroy the inline content of the first writer.
|
||||
EXPECT_EQ(str, w.str());
|
||||
EXPECT_EQ(str, w2.str());
|
||||
}
|
||||
|
||||
TEST(WriterTest, MoveCtor) {
|
||||
MemoryWriter w;
|
||||
w.write("test");
|
||||
check_move_writer("test", w);
|
||||
// This fills the inline buffer, but doesn't cause dynamic allocation.
|
||||
std::string s;
|
||||
for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE; ++i)
|
||||
s += '*';
|
||||
w.clear();
|
||||
w.write(s);
|
||||
check_move_writer(s, w);
|
||||
const char *inline_buffer_ptr = w.data();
|
||||
// Adding one more character causes the content to move from the inline to
|
||||
// a dynamically allocated buffer.
|
||||
w.write('*');
|
||||
MemoryWriter w2(std::move(w));
|
||||
// Move should rip the guts of the first writer.
|
||||
EXPECT_EQ(inline_buffer_ptr, w.data());
|
||||
EXPECT_EQ(s + '*', w2.str());
|
||||
}
|
||||
|
||||
void CheckMoveAssignWriter(const std::string &str, MemoryWriter &w) {
|
||||
MemoryWriter w2;
|
||||
w2 = std::move(w);
|
||||
// Move shouldn't destroy the inline content of the first writer.
|
||||
EXPECT_EQ(str, w.str());
|
||||
EXPECT_EQ(str, w2.str());
|
||||
}
|
||||
|
||||
TEST(WriterTest, MoveAssignment) {
|
||||
MemoryWriter w;
|
||||
w.write("test");
|
||||
CheckMoveAssignWriter("test", w);
|
||||
// This fills the inline buffer, but doesn't cause dynamic allocation.
|
||||
std::string s;
|
||||
for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE; ++i)
|
||||
s += '*';
|
||||
w.clear();
|
||||
w.write(s);
|
||||
CheckMoveAssignWriter(s, w);
|
||||
const char *inline_buffer_ptr = w.data();
|
||||
// Adding one more character causes the content to move from the inline to
|
||||
// a dynamically allocated buffer.
|
||||
w.write('*');
|
||||
MemoryWriter w2;
|
||||
w2 = std::move(w);
|
||||
// Move should rip the guts of the first writer.
|
||||
EXPECT_EQ(inline_buffer_ptr, w.data());
|
||||
EXPECT_EQ(s + '*', w2.str());
|
||||
}
|
||||
|
||||
#endif // FMT_USE_RVALUE_REFERENCES
|
||||
|
||||
TEST(WriterTest, Allocator) {
|
||||
typedef testing::StrictMock< MockAllocator<char> > MockAllocator;
|
||||
typedef AllocatorRef<MockAllocator> TestAllocator;
|
||||
MockAllocator alloc;
|
||||
fmt::BasicMemoryWriter<char, TestAllocator> w((TestAllocator(&alloc)));
|
||||
std::size_t size =
|
||||
static_cast<std::size_t>(1.5 * fmt::internal::INLINE_BUFFER_SIZE);
|
||||
std::vector<char> mem(size);
|
||||
EXPECT_CALL(alloc, allocate(size)).WillOnce(testing::Return(&mem[0]));
|
||||
for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE + 1; ++i)
|
||||
w.write('*');
|
||||
EXPECT_CALL(alloc, deallocate(&mem[0], size));
|
||||
}
|
||||
|
||||
TEST(WriterTest, Data) {
|
||||
MemoryWriter w;
|
||||
memory_buffer buf;
|
||||
fmt::basic_writer<char> w(buf);
|
||||
w.write(42);
|
||||
EXPECT_EQ("42", std::string(w.data(), w.size()));
|
||||
}
|
||||
@@ -312,13 +239,15 @@ TEST(WriterTest, WriteLongDouble) {
|
||||
}
|
||||
|
||||
TEST(WriterTest, WriteDoubleAtBufferBoundary) {
|
||||
MemoryWriter writer;
|
||||
memory_buffer buf;
|
||||
fmt::basic_writer<char> writer(buf);
|
||||
for (int i = 0; i < 100; ++i)
|
||||
writer.write(1.23456789);
|
||||
}
|
||||
|
||||
TEST(WriterTest, WriteDoubleWithFilledBuffer) {
|
||||
MemoryWriter writer;
|
||||
memory_buffer buf;
|
||||
fmt::basic_writer<char> writer(buf);
|
||||
// Fill the buffer.
|
||||
for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE; ++i)
|
||||
writer.write(' ');
|
||||
@@ -349,7 +278,8 @@ TEST(WriterTest, WriteWideString) {
|
||||
|
||||
template <typename... T>
|
||||
std::string write_str(T... args) {
|
||||
MemoryWriter writer;
|
||||
memory_buffer buf;
|
||||
fmt::basic_writer<char> writer(buf);
|
||||
using namespace fmt;
|
||||
writer.write(args...);
|
||||
return writer.str();
|
||||
@@ -357,7 +287,8 @@ std::string write_str(T... args) {
|
||||
|
||||
template <typename... T>
|
||||
std::wstring write_wstr(T... args) {
|
||||
WMemoryWriter writer;
|
||||
wmemory_buffer buf;
|
||||
fmt::basic_writer<wchar_t> writer(buf);
|
||||
using namespace fmt;
|
||||
writer.write(args...);
|
||||
return writer.str();
|
||||
@@ -447,7 +378,8 @@ TEST(WriterTest, pad) {
|
||||
EXPECT_EQ(" 33", write_str(33ll, width=7));
|
||||
EXPECT_EQ(" 44", write_str(44ull, width=7));
|
||||
|
||||
MemoryWriter w;
|
||||
memory_buffer buf;
|
||||
fmt::basic_writer<char> w(buf);
|
||||
w.clear();
|
||||
w.write(42, fmt::width=5, fmt::fill='0');
|
||||
EXPECT_EQ("00042", w.str());
|
||||
@@ -475,13 +407,13 @@ TEST(WriterTest, WWriter) {
|
||||
}
|
||||
|
||||
TEST(FormatToTest, FormatWithoutArgs) {
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
format_to(buffer, "test");
|
||||
EXPECT_EQ("test", std::string(buffer.data(), buffer.size()));
|
||||
}
|
||||
|
||||
TEST(FormatToTest, Format) {
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
format_to(buffer, "part{0}", 1);
|
||||
EXPECT_EQ(strlen("part1"), buffer.size());
|
||||
EXPECT_EQ("part1", std::string(buffer.data(), buffer.size()));
|
||||
@@ -1370,18 +1302,9 @@ TEST(FormatterTest, FormatExamples) {
|
||||
EXPECT_EQ("42", format("{}", 42));
|
||||
EXPECT_EQ("42", format(std::string("{}"), 42));
|
||||
|
||||
MemoryWriter out;
|
||||
out.write("The answer is ");
|
||||
out.write(42);
|
||||
out.write("\n");
|
||||
|
||||
{
|
||||
MemoryWriter writer;
|
||||
for (int i = 0; i < 10; i++)
|
||||
format_to(writer.buffer(), "{}", i);
|
||||
std::string s = writer.str(); // s == 0123456789
|
||||
EXPECT_EQ("0123456789", s);
|
||||
}
|
||||
memory_buffer out;
|
||||
format_to(out, "The answer is {}.", 42);
|
||||
EXPECT_EQ("The answer is 42.", to_string(out));
|
||||
|
||||
const char *filename = "nonexistent";
|
||||
FILE *ftest = safe_fopen(filename, "r");
|
||||
@@ -1522,7 +1445,7 @@ TEST(StrTest, Convert) {
|
||||
}
|
||||
|
||||
std::string vformat_message(int id, const char *format, fmt::args args) {
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
format_to(buffer, "[{}] ", id);
|
||||
vformat_to(buffer, format, args);
|
||||
return to_string(buffer);
|
||||
@@ -1612,7 +1535,7 @@ class MockArgFormatter : public fmt::internal::ArgFormatterBase<char> {
|
||||
};
|
||||
|
||||
void custom_vformat(fmt::CStringRef format_str, fmt::args args) {
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::vformat_to<MockArgFormatter>(buffer, format_str, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -319,9 +319,9 @@ TEST(StreamingAssertionsTest, EXPECT_WRITE) {
|
||||
}
|
||||
|
||||
TEST(UtilTest, FormatSystemError) {
|
||||
fmt::MemoryWriter out;
|
||||
fmt::format_system_error(out.buffer(), EDOM, "test message");
|
||||
EXPECT_EQ(out.str(), format_system_error(EDOM, "test message"));
|
||||
fmt::memory_buffer out;
|
||||
fmt::format_system_error(out, EDOM, "test message");
|
||||
EXPECT_EQ(to_string(out), format_system_error(EDOM, "test message"));
|
||||
}
|
||||
|
||||
#if FMT_USE_FILE_DESCRIPTORS
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ std::string read(File &f, std::size_t count) {
|
||||
#endif // FMT_USE_FILE_DESCRIPTORS
|
||||
|
||||
std::string format_system_error(int error_code, fmt::string_view message) {
|
||||
fmt::internal::MemoryBuffer<char> out;
|
||||
fmt::format_system_error(out, error_code, message);
|
||||
fmt::memory_buffer out;
|
||||
format_system_error(out, error_code, message);
|
||||
return to_string(out);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ struct TestArgFormatter : fmt::arg_formatter<char> {
|
||||
};
|
||||
|
||||
TEST(OStreamTest, CustomArg) {
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::context ctx("}", fmt::args());
|
||||
fmt::format_specs spec;
|
||||
TestArgFormatter af(buffer, ctx, spec);
|
||||
@@ -121,7 +121,7 @@ TEST(OStreamTest, Print) {
|
||||
|
||||
TEST(OStreamTest, WriteToOStream) {
|
||||
std::ostringstream os;
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
const char *foo = "foo";
|
||||
buffer.append(foo, foo + std::strlen(foo));
|
||||
fmt::internal::write(os, buffer);
|
||||
|
||||
+20
-19
@@ -54,8 +54,8 @@
|
||||
|
||||
using fmt::basic_arg;
|
||||
using fmt::basic_buffer;
|
||||
using fmt::basic_memory_buffer;
|
||||
using fmt::string_view;
|
||||
using fmt::internal::MemoryBuffer;
|
||||
using fmt::internal::value;
|
||||
|
||||
using testing::_;
|
||||
@@ -238,7 +238,7 @@ TEST(BufferTest, AppendAllocatesEnoughStorage) {
|
||||
}
|
||||
|
||||
TEST(MemoryBufferTest, Ctor) {
|
||||
MemoryBuffer<char, 123> buffer;
|
||||
basic_memory_buffer<char, 123> buffer;
|
||||
EXPECT_EQ(0u, buffer.size());
|
||||
EXPECT_EQ(123u, buffer.capacity());
|
||||
}
|
||||
@@ -248,9 +248,9 @@ TEST(MemoryBufferTest, Ctor) {
|
||||
typedef AllocatorRef< std::allocator<char> > TestAllocator;
|
||||
|
||||
void check_move_buffer(const char *str,
|
||||
MemoryBuffer<char, 5, TestAllocator> &buffer) {
|
||||
basic_memory_buffer<char, 5, TestAllocator> &buffer) {
|
||||
std::allocator<char> *alloc = buffer.get_allocator().get();
|
||||
MemoryBuffer<char, 5, TestAllocator> buffer2(std::move(buffer));
|
||||
basic_memory_buffer<char, 5, TestAllocator> buffer2(std::move(buffer));
|
||||
// Move shouldn't destroy the inline content of the first buffer.
|
||||
EXPECT_EQ(str, std::string(&buffer[0], buffer.size()));
|
||||
EXPECT_EQ(str, std::string(&buffer2[0], buffer2.size()));
|
||||
@@ -262,7 +262,7 @@ void check_move_buffer(const char *str,
|
||||
|
||||
TEST(MemoryBufferTest, MoveCtor) {
|
||||
std::allocator<char> alloc;
|
||||
MemoryBuffer<char, 5, TestAllocator> buffer((TestAllocator(&alloc)));
|
||||
basic_memory_buffer<char, 5, TestAllocator> buffer((TestAllocator(&alloc)));
|
||||
const char test[] = "test";
|
||||
buffer.append(test, test + 4);
|
||||
check_move_buffer("test", buffer);
|
||||
@@ -274,15 +274,16 @@ TEST(MemoryBufferTest, MoveCtor) {
|
||||
// Adding one more character causes the content to move from the inline to
|
||||
// a dynamically allocated buffer.
|
||||
buffer.push_back('b');
|
||||
MemoryBuffer<char, 5, TestAllocator> buffer2(std::move(buffer));
|
||||
basic_memory_buffer<char, 5, TestAllocator> buffer2(std::move(buffer));
|
||||
// Move should rip the guts of the first buffer.
|
||||
EXPECT_EQ(inline_buffer_ptr, &buffer[0]);
|
||||
EXPECT_EQ("testab", std::string(&buffer2[0], buffer2.size()));
|
||||
EXPECT_GT(buffer2.capacity(), 5u);
|
||||
}
|
||||
|
||||
void check_move_assign_buffer(const char *str, MemoryBuffer<char, 5> &buffer) {
|
||||
MemoryBuffer<char, 5> buffer2;
|
||||
void check_move_assign_buffer(
|
||||
const char *str, basic_memory_buffer<char, 5> &buffer) {
|
||||
basic_memory_buffer<char, 5> buffer2;
|
||||
buffer2 = std::move(buffer);
|
||||
// Move shouldn't destroy the inline content of the first buffer.
|
||||
EXPECT_EQ(str, std::string(&buffer[0], buffer.size()));
|
||||
@@ -291,7 +292,7 @@ void check_move_assign_buffer(const char *str, MemoryBuffer<char, 5> &buffer) {
|
||||
}
|
||||
|
||||
TEST(MemoryBufferTest, MoveAssignment) {
|
||||
MemoryBuffer<char, 5> buffer;
|
||||
basic_memory_buffer<char, 5> buffer;
|
||||
const char test[] = "test";
|
||||
buffer.append(test, test + 4);
|
||||
check_move_assign_buffer("test", buffer);
|
||||
@@ -303,7 +304,7 @@ TEST(MemoryBufferTest, MoveAssignment) {
|
||||
// Adding one more character causes the content to move from the inline to
|
||||
// a dynamically allocated buffer.
|
||||
buffer.push_back('b');
|
||||
MemoryBuffer<char, 5> buffer2;
|
||||
basic_memory_buffer<char, 5> buffer2;
|
||||
buffer2 = std::move(buffer);
|
||||
// Move should rip the guts of the first buffer.
|
||||
EXPECT_EQ(inline_buffer_ptr, &buffer[0]);
|
||||
@@ -315,7 +316,7 @@ TEST(MemoryBufferTest, MoveAssignment) {
|
||||
|
||||
TEST(MemoryBufferTest, Grow) {
|
||||
typedef AllocatorRef< MockAllocator<int> > Allocator;
|
||||
typedef MemoryBuffer<int, 10, Allocator> Base;
|
||||
typedef basic_memory_buffer<int, 10, Allocator> Base;
|
||||
MockAllocator<int> alloc;
|
||||
struct TestMemoryBuffer : Base {
|
||||
TestMemoryBuffer(Allocator alloc) : Base(alloc) {}
|
||||
@@ -341,12 +342,12 @@ TEST(MemoryBufferTest, Grow) {
|
||||
|
||||
TEST(MemoryBufferTest, Allocator) {
|
||||
typedef AllocatorRef< MockAllocator<char> > TestAllocator;
|
||||
MemoryBuffer<char, 10, TestAllocator> buffer;
|
||||
basic_memory_buffer<char, 10, TestAllocator> buffer;
|
||||
EXPECT_EQ(0, buffer.get_allocator().get());
|
||||
StrictMock< MockAllocator<char> > alloc;
|
||||
char mem;
|
||||
{
|
||||
MemoryBuffer<char, 10, TestAllocator> buffer2((TestAllocator(&alloc)));
|
||||
basic_memory_buffer<char, 10, TestAllocator> buffer2((TestAllocator(&alloc)));
|
||||
EXPECT_EQ(&alloc, buffer2.get_allocator().get());
|
||||
std::size_t size = 2 * fmt::internal::INLINE_BUFFER_SIZE;
|
||||
EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem));
|
||||
@@ -358,7 +359,7 @@ TEST(MemoryBufferTest, Allocator) {
|
||||
TEST(MemoryBufferTest, ExceptionInDeallocate) {
|
||||
typedef AllocatorRef< MockAllocator<char> > TestAllocator;
|
||||
StrictMock< MockAllocator<char> > alloc;
|
||||
MemoryBuffer<char, 10, TestAllocator> buffer((TestAllocator(&alloc)));
|
||||
basic_memory_buffer<char, 10, TestAllocator> buffer((TestAllocator(&alloc)));
|
||||
std::size_t size = 2 * fmt::internal::INLINE_BUFFER_SIZE;
|
||||
std::vector<char> mem(size);
|
||||
{
|
||||
@@ -435,7 +436,7 @@ TEST(UtilTest, MakeValueWithCustomFormatter) {
|
||||
::Test t;
|
||||
fmt::internal::value<CustomContext> arg(t);
|
||||
CustomContext ctx = {false};
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
arg.custom.format(buffer, &t, &ctx);
|
||||
EXPECT_TRUE(ctx.called);
|
||||
}
|
||||
@@ -579,7 +580,7 @@ TEST(UtilTest, CustomArg) {
|
||||
EXPECT_CALL(visitor, visit(_)).WillOnce(
|
||||
testing::Invoke([&](fmt::internal::CustomValue<char> custom) {
|
||||
EXPECT_EQ(&test, custom.value);
|
||||
fmt::internal::MemoryBuffer<char> buffer;
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::context ctx("}", fmt::args());
|
||||
custom.format(buffer, &test, &ctx);
|
||||
EXPECT_EQ("test", std::string(buffer.data(), buffer.size()));
|
||||
@@ -710,14 +711,14 @@ void check_throw_error(int error_code, FormatErrorMessage format) {
|
||||
} catch (const fmt::SystemError &e) {
|
||||
error = e;
|
||||
}
|
||||
fmt::internal::MemoryBuffer<char> message;
|
||||
fmt::memory_buffer message;
|
||||
format(message, error_code, "test error");
|
||||
EXPECT_EQ(to_string(message), error.what());
|
||||
EXPECT_EQ(error_code, error.error_code());
|
||||
}
|
||||
|
||||
TEST(UtilTest, FormatSystemError) {
|
||||
fmt::internal::MemoryBuffer<char> message;
|
||||
fmt::memory_buffer message;
|
||||
fmt::format_system_error(message, EDOM, "test");
|
||||
EXPECT_EQ(fmt::format("test: {}", get_system_error(EDOM)),
|
||||
to_string(message));
|
||||
@@ -735,7 +736,7 @@ TEST(UtilTest, SystemError) {
|
||||
}
|
||||
|
||||
TEST(UtilTest, ReportSystemError) {
|
||||
fmt::internal::MemoryBuffer<char> out;
|
||||
fmt::memory_buffer out;
|
||||
fmt::format_system_error(out, EDOM, "test error");
|
||||
out.push_back('\n');
|
||||
EXPECT_WRITE(stderr, fmt::report_system_error(EDOM, "test error"),
|
||||
|
||||
Reference in New Issue
Block a user