From 39623a7400026a7ec492aa813f11f3a3b9f4479c Mon Sep 17 00:00:00 2001 From: Michael Winterberg Date: Wed, 2 Jan 2019 10:03:04 -0800 Subject: [PATCH] Replaced usage of gtest's internal scoped_ptr with unique_ptr. scoped_ptr was removed in with gtest google/googletest@e857f9cdd998136b9aad634272301f5b2d0476ea. --- test/gtest-extra-test.cc | 11 +++++------ test/posix-mock-test.cc | 12 ++++++------ test/posix-test.cc | 7 +++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index 43088db4..8acf8b9b 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -7,8 +7,9 @@ #include "gtest-extra.h" -#include #include +#include +#include #include #include @@ -18,8 +19,6 @@ #include "util.h" -using testing::internal::scoped_ptr; - namespace { // This is used to suppress coverity warnings about untrusted values. @@ -340,7 +339,7 @@ TEST(OutputRedirectTest, FlushErrorInCtor) { // Put a character in a file buffer. EXPECT_EQ('x', fputc('x', f.get())); FMT_POSIX(close(write_fd)); - scoped_ptr redir{FMT_NULL}; + std::unique_ptr redir{FMT_NULL}; EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())), EBADF, "cannot flush stream"); redir.reset(FMT_NULL); @@ -352,7 +351,7 @@ TEST(OutputRedirectTest, DupErrorInCtor) { int fd = (f.fileno)(); file copy = file::dup(fd); FMT_POSIX(close(fd)); - scoped_ptr redir{FMT_NULL}; + std::unique_ptr redir{FMT_NULL}; EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())), EBADF, fmt::format("cannot duplicate file descriptor {}", fd)); copy.dup2(fd); // "undo" close or dtor will fail @@ -394,7 +393,7 @@ TEST(OutputRedirectTest, ErrorInDtor) { int write_fd = write_end.descriptor(); file write_copy = write_end.dup(write_fd); buffered_file f = write_end.fdopen("w"); - scoped_ptr redir(new OutputRedirect(f.get())); + std::unique_ptr redir(new OutputRedirect(f.get())); // Put a character in a file buffer. EXPECT_EQ('x', fputc('x', f.get())); EXPECT_WRITE(stderr, { diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index 8b0e14e1..e1cc9687 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -13,9 +13,10 @@ #include "posix-mock.h" #include "../src/posix.cc" +#include #include #include -#include +#include #ifdef _WIN32 # include @@ -31,7 +32,6 @@ using fmt::buffered_file; using fmt::error_code; using fmt::file; -using testing::internal::scoped_ptr; using testing::_; using testing::StrEq; using testing::Return; @@ -216,7 +216,7 @@ TEST(UtilTest, GetPageSize) { TEST(FileTest, OpenRetry) { write_file("test", "there must be something here"); - scoped_ptr f{FMT_NULL}; + std::unique_ptr f{FMT_NULL}; EXPECT_RETRY(f.reset(new file("test", file::RDONLY)), open, "cannot open file test"); #ifndef _WIN32 @@ -228,7 +228,7 @@ TEST(FileTest, OpenRetry) { TEST(FileTest, CloseNoRetryInDtor) { file read_end, write_end; file::pipe(read_end, write_end); - scoped_ptr f(new file(std::move(read_end))); + std::unique_ptr f(new file(std::move(read_end))); int saved_close_count = 0; EXPECT_WRITE(stderr, { close_count = 1; @@ -385,7 +385,7 @@ TEST(FileTest, FdopenNoRetry) { TEST(BufferedFileTest, OpenRetry) { write_file("test", "there must be something here"); - scoped_ptr f{FMT_NULL}; + std::unique_ptr f{FMT_NULL}; EXPECT_RETRY(f.reset(new buffered_file("test", "r")), fopen, "cannot open file test"); #ifndef _WIN32 @@ -398,7 +398,7 @@ TEST(BufferedFileTest, OpenRetry) { TEST(BufferedFileTest, CloseNoRetryInDtor) { file read_end, write_end; file::pipe(read_end, write_end); - scoped_ptr f(new buffered_file(read_end.fdopen("r"))); + std::unique_ptr f(new buffered_file(read_end.fdopen("r"))); int saved_fclose_count = 0; EXPECT_WRITE(stderr, { fclose_count = 1; diff --git a/test/posix-test.cc b/test/posix-test.cc index fbd4568a..868732c3 100644 --- a/test/posix-test.cc +++ b/test/posix-test.cc @@ -7,6 +7,7 @@ #include // std::exit #include +#include #include "fmt/posix.h" #include "gtest-extra.h" @@ -20,8 +21,6 @@ using fmt::buffered_file; using fmt::error_code; using fmt::file; -using testing::internal::scoped_ptr; - // Checks if the file is open by reading one character from it. static bool isopen(int fd) { char buffer; @@ -119,7 +118,7 @@ TEST(BufferedFileTest, CloseFileInDtor) { } TEST(BufferedFileTest, CloseErrorInDtor) { - scoped_ptr f(new buffered_file(open_buffered_file())); + std::unique_ptr f(new buffered_file(open_buffered_file())); EXPECT_WRITE(stderr, { // The close function must be called inside EXPECT_WRITE, otherwise // the system may recycle closed file descriptor when redirecting the @@ -246,7 +245,7 @@ TEST(FileTest, CloseFileInDtor) { } TEST(FileTest, CloseErrorInDtor) { - scoped_ptr f(new file(open_file())); + std::unique_ptr f(new file(open_file())); EXPECT_WRITE(stderr, { // The close function must be called inside EXPECT_WRITE, otherwise // the system may recycle closed file descriptor when redirecting the