mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-04 15:40:07 +00:00
Make flush public
This commit is contained in:
parent
f1794a8853
commit
bba0a9d962
@ -401,12 +401,6 @@ class FMT_API ostream final : private detail::buffer<char> {
|
||||
private:
|
||||
file file_;
|
||||
|
||||
void flush() {
|
||||
if (size() == 0) return;
|
||||
file_.write(data(), size());
|
||||
clear();
|
||||
}
|
||||
|
||||
void grow(size_t) override;
|
||||
|
||||
ostream(cstring_view path, const detail::ostream_params& params)
|
||||
@ -426,6 +420,12 @@ class FMT_API ostream final : private detail::buffer<char> {
|
||||
delete[] data();
|
||||
}
|
||||
|
||||
void flush() {
|
||||
if (size() == 0) return;
|
||||
file_.write(data(), size());
|
||||
clear();
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
friend ostream output_file(cstring_view path, T... params);
|
||||
|
||||
|
@ -336,6 +336,14 @@ TEST(ostream_test, truncate) {
|
||||
EXPECT_EQ("foo", read(in, 4));
|
||||
}
|
||||
|
||||
TEST(ostream_test, flush) {
|
||||
auto out = fmt::output_file("test-file");
|
||||
out.print("x");
|
||||
out.flush();
|
||||
auto in = fmt::file("test-file", file::RDONLY);
|
||||
EXPECT_READ(in, "x");
|
||||
}
|
||||
|
||||
TEST(file_test, default_ctor) {
|
||||
file f;
|
||||
EXPECT_EQ(-1, f.descriptor());
|
||||
|
Loading…
x
Reference in New Issue
Block a user