Add support for line buffering
This commit is contained in:
@@ -1752,6 +1752,21 @@ TEST(format_test, big_print) {
|
||||
EXPECT_WRITE(stdout, big_print(), std::string(count, 'x'));
|
||||
}
|
||||
|
||||
// Windows CRT implements _IOLBF incorrectly (full buffering).
|
||||
#if FMT_USE_FCNTL && !defined(_WIN32)
|
||||
TEST(format_test, line_buffering) {
|
||||
auto pipe = fmt::pipe();
|
||||
auto read_end = pipe.read_end.fdopen("r");
|
||||
auto write_end = pipe.write_end.fdopen("w");
|
||||
setvbuf(write_end.get(), nullptr, _IOLBF, 4096);
|
||||
write_end.print("42\n");
|
||||
int n = 0;
|
||||
int result = fscanf(read_end.get(), "%d", &n);
|
||||
(void)result;
|
||||
EXPECT_EQ(n, 42);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(format_test, variadic) {
|
||||
EXPECT_EQ(fmt::format("{}c{}", "ab", 1), "abc1");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user