From e654f56210a96207e4f897cbc66502da5ba78490 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 18 May 2014 10:04:49 -0700 Subject: [PATCH] Test fdopen. --- test/gtest-extra-test.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index a9a8a4d4..bdd13805 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -712,6 +712,19 @@ TEST(FileTest, Pipe) { EXPECT_READ(read_end, "test"); } +TEST(FileTest, Fdopen) { + File read_end, write_end; + File::pipe(read_end, write_end); + int read_fd = read_end.descriptor(); + EXPECT_EQ(read_fd, fileno(read_end.fdopen("r").get())); +} + +TEST(FileTest, FdopenError) { + File f; + EXPECT_SYSTEM_ERROR_NOASSERT( + f.fdopen("r"), EBADF, "cannot associate stream with file descriptor"); +} + TEST(OutputRedirectTest, ScopedRedirect) { File read_end, write_end; File::pipe(read_end, write_end);