mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-09 21:00:06 +00:00
Make gtest-extra-test more portable
This commit is contained in:
parent
bea7ecc710
commit
ffa5b14fe3
@ -354,7 +354,7 @@ TEST(output_redirect_test, dup_error_in_ctor) {
|
|||||||
FMT_POSIX(close(fd));
|
FMT_POSIX(close(fd));
|
||||||
std::unique_ptr<output_redirect> redir{nullptr};
|
std::unique_ptr<output_redirect> redir{nullptr};
|
||||||
EXPECT_SYSTEM_ERROR_NOASSERT(
|
EXPECT_SYSTEM_ERROR_NOASSERT(
|
||||||
redir.reset(new output_redirect(f.get())), EBADF,
|
redir.reset(new output_redirect(f.get(), false)), EBADF,
|
||||||
fmt::format("cannot duplicate file descriptor {}", fd));
|
fmt::format("cannot duplicate file descriptor {}", fd));
|
||||||
copy.dup2(fd); // "undo" close or dtor will fail
|
copy.dup2(fd); // "undo" close or dtor will fail
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
using fmt::file;
|
using fmt::file;
|
||||||
|
|
||||||
output_redirect::output_redirect(FILE* f) : file_(f) {
|
output_redirect::output_redirect(FILE* f, bool flush) : file_(f) {
|
||||||
flush();
|
if (flush) this->flush();
|
||||||
int fd = FMT_POSIX(fileno(f));
|
int fd = FMT_POSIX(fileno(f));
|
||||||
// Create a file object referring to the original file.
|
// Create a file object referring to the original file.
|
||||||
original_ = file::dup(fd);
|
original_ = file::dup(fd);
|
||||||
|
@ -77,7 +77,7 @@ class output_redirect {
|
|||||||
void restore();
|
void restore();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit output_redirect(FILE* file);
|
explicit output_redirect(FILE* file, bool flush = true);
|
||||||
~output_redirect() noexcept;
|
~output_redirect() noexcept;
|
||||||
|
|
||||||
output_redirect(const output_redirect&) = delete;
|
output_redirect(const output_redirect&) = delete;
|
||||||
|
Loading…
Reference in New Issue
Block a user