Write directly to a stream buffer

This commit is contained in:
Victor Zverovich
2024-01-18 07:27:59 -08:00
parent b2cde48de5
commit 6b68dff901
4 changed files with 172 additions and 85 deletions

View File

@@ -1741,6 +1741,14 @@ TEST(format_test, print) {
"Don't panic!\n");
}
TEST(format_test, big_print) {
enum {count = 5000};
auto big_print = []() {
for (int i = 0; i < count / 5; ++i) fmt::print("xxxxx");
};
EXPECT_WRITE(stdout, big_print(), std::string(count, 'x'));
}
TEST(format_test, variadic) {
EXPECT_EQ(fmt::format("{}c{}", "ab", 1), "abc1");
}