mirror of
https://github.com/fmtlib/fmt.git
synced 2026-05-04 03:40:49 +02:00
Separate memory management and formatting
Array is split into an abstract Buffer class and a concrete MemoryBuffer class. BasicWriter now does all memory allocation through a Buffer object. Subclasses of BasicWriter may use different buffer types. The new BasicMemoryBuffer class uses the default MemoryBuffer.
This commit is contained in:
@@ -88,20 +88,20 @@ TEST(FormatTest, StrError) {
|
||||
TEST(FormatTest, FormatErrorCode) {
|
||||
std::string msg = "error 42", sep = ": ";
|
||||
{
|
||||
fmt::Writer w;
|
||||
fmt::MemoryWriter w;
|
||||
w << "garbage";
|
||||
format_error_code(w, 42, "test");
|
||||
EXPECT_EQ("test: " + msg, w.str());
|
||||
}
|
||||
{
|
||||
fmt::Writer w;
|
||||
fmt::MemoryWriter w;
|
||||
std::string prefix(
|
||||
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size() + 1, 'x');
|
||||
format_error_code(w, 42, prefix);
|
||||
EXPECT_EQ(msg, w.str());
|
||||
}
|
||||
{
|
||||
fmt::Writer w;
|
||||
fmt::MemoryWriter w;
|
||||
std::string prefix(
|
||||
fmt::internal::INLINE_BUFFER_SIZE - msg.size() - sep.size(), 'x');
|
||||
format_error_code(w, 42, prefix);
|
||||
|
||||
Reference in New Issue
Block a user