mirror of
https://github.com/fmtlib/fmt.git
synced 2025-04-24 09:02:32 +00:00
Replaced usage of gtest's internal scoped_ptr with unique_ptr.
scoped_ptr was removed in with gtest google/googletest@e857f9cdd9.
This commit is contained in:
parent
ae1de3a8d3
commit
39623a7400
@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <gtest/gtest-spi.h>
|
#include <gtest/gtest-spi.h>
|
||||||
|
|
||||||
@ -18,8 +19,6 @@
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
using testing::internal::scoped_ptr;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// This is used to suppress coverity warnings about untrusted values.
|
// This is used to suppress coverity warnings about untrusted values.
|
||||||
@ -340,7 +339,7 @@ TEST(OutputRedirectTest, FlushErrorInCtor) {
|
|||||||
// Put a character in a file buffer.
|
// Put a character in a file buffer.
|
||||||
EXPECT_EQ('x', fputc('x', f.get()));
|
EXPECT_EQ('x', fputc('x', f.get()));
|
||||||
FMT_POSIX(close(write_fd));
|
FMT_POSIX(close(write_fd));
|
||||||
scoped_ptr<OutputRedirect> redir{FMT_NULL};
|
std::unique_ptr<OutputRedirect> redir{FMT_NULL};
|
||||||
EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())),
|
EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())),
|
||||||
EBADF, "cannot flush stream");
|
EBADF, "cannot flush stream");
|
||||||
redir.reset(FMT_NULL);
|
redir.reset(FMT_NULL);
|
||||||
@ -352,7 +351,7 @@ TEST(OutputRedirectTest, DupErrorInCtor) {
|
|||||||
int fd = (f.fileno)();
|
int fd = (f.fileno)();
|
||||||
file copy = file::dup(fd);
|
file copy = file::dup(fd);
|
||||||
FMT_POSIX(close(fd));
|
FMT_POSIX(close(fd));
|
||||||
scoped_ptr<OutputRedirect> redir{FMT_NULL};
|
std::unique_ptr<OutputRedirect> redir{FMT_NULL};
|
||||||
EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())),
|
EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new OutputRedirect(f.get())),
|
||||||
EBADF, fmt::format("cannot duplicate file descriptor {}", fd));
|
EBADF, 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
|
||||||
@ -394,7 +393,7 @@ TEST(OutputRedirectTest, ErrorInDtor) {
|
|||||||
int write_fd = write_end.descriptor();
|
int write_fd = write_end.descriptor();
|
||||||
file write_copy = write_end.dup(write_fd);
|
file write_copy = write_end.dup(write_fd);
|
||||||
buffered_file f = write_end.fdopen("w");
|
buffered_file f = write_end.fdopen("w");
|
||||||
scoped_ptr<OutputRedirect> redir(new OutputRedirect(f.get()));
|
std::unique_ptr<OutputRedirect> redir(new OutputRedirect(f.get()));
|
||||||
// Put a character in a file buffer.
|
// Put a character in a file buffer.
|
||||||
EXPECT_EQ('x', fputc('x', f.get()));
|
EXPECT_EQ('x', fputc('x', f.get()));
|
||||||
EXPECT_WRITE(stderr, {
|
EXPECT_WRITE(stderr, {
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
#include "posix-mock.h"
|
#include "posix-mock.h"
|
||||||
#include "../src/posix.cc"
|
#include "../src/posix.cc"
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <climits>
|
#include <memory>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
@ -31,7 +32,6 @@ using fmt::buffered_file;
|
|||||||
using fmt::error_code;
|
using fmt::error_code;
|
||||||
using fmt::file;
|
using fmt::file;
|
||||||
|
|
||||||
using testing::internal::scoped_ptr;
|
|
||||||
using testing::_;
|
using testing::_;
|
||||||
using testing::StrEq;
|
using testing::StrEq;
|
||||||
using testing::Return;
|
using testing::Return;
|
||||||
@ -216,7 +216,7 @@ TEST(UtilTest, GetPageSize) {
|
|||||||
|
|
||||||
TEST(FileTest, OpenRetry) {
|
TEST(FileTest, OpenRetry) {
|
||||||
write_file("test", "there must be something here");
|
write_file("test", "there must be something here");
|
||||||
scoped_ptr<file> f{FMT_NULL};
|
std::unique_ptr<file> f{FMT_NULL};
|
||||||
EXPECT_RETRY(f.reset(new file("test", file::RDONLY)),
|
EXPECT_RETRY(f.reset(new file("test", file::RDONLY)),
|
||||||
open, "cannot open file test");
|
open, "cannot open file test");
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -228,7 +228,7 @@ TEST(FileTest, OpenRetry) {
|
|||||||
TEST(FileTest, CloseNoRetryInDtor) {
|
TEST(FileTest, CloseNoRetryInDtor) {
|
||||||
file read_end, write_end;
|
file read_end, write_end;
|
||||||
file::pipe(read_end, write_end);
|
file::pipe(read_end, write_end);
|
||||||
scoped_ptr<file> f(new file(std::move(read_end)));
|
std::unique_ptr<file> f(new file(std::move(read_end)));
|
||||||
int saved_close_count = 0;
|
int saved_close_count = 0;
|
||||||
EXPECT_WRITE(stderr, {
|
EXPECT_WRITE(stderr, {
|
||||||
close_count = 1;
|
close_count = 1;
|
||||||
@ -385,7 +385,7 @@ TEST(FileTest, FdopenNoRetry) {
|
|||||||
|
|
||||||
TEST(BufferedFileTest, OpenRetry) {
|
TEST(BufferedFileTest, OpenRetry) {
|
||||||
write_file("test", "there must be something here");
|
write_file("test", "there must be something here");
|
||||||
scoped_ptr<buffered_file> f{FMT_NULL};
|
std::unique_ptr<buffered_file> f{FMT_NULL};
|
||||||
EXPECT_RETRY(f.reset(new buffered_file("test", "r")),
|
EXPECT_RETRY(f.reset(new buffered_file("test", "r")),
|
||||||
fopen, "cannot open file test");
|
fopen, "cannot open file test");
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -398,7 +398,7 @@ TEST(BufferedFileTest, OpenRetry) {
|
|||||||
TEST(BufferedFileTest, CloseNoRetryInDtor) {
|
TEST(BufferedFileTest, CloseNoRetryInDtor) {
|
||||||
file read_end, write_end;
|
file read_end, write_end;
|
||||||
file::pipe(read_end, write_end);
|
file::pipe(read_end, write_end);
|
||||||
scoped_ptr<buffered_file> f(new buffered_file(read_end.fdopen("r")));
|
std::unique_ptr<buffered_file> f(new buffered_file(read_end.fdopen("r")));
|
||||||
int saved_fclose_count = 0;
|
int saved_fclose_count = 0;
|
||||||
EXPECT_WRITE(stderr, {
|
EXPECT_WRITE(stderr, {
|
||||||
fclose_count = 1;
|
fclose_count = 1;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <cstdlib> // std::exit
|
#include <cstdlib> // std::exit
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "fmt/posix.h"
|
#include "fmt/posix.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
@ -20,8 +21,6 @@ using fmt::buffered_file;
|
|||||||
using fmt::error_code;
|
using fmt::error_code;
|
||||||
using fmt::file;
|
using fmt::file;
|
||||||
|
|
||||||
using testing::internal::scoped_ptr;
|
|
||||||
|
|
||||||
// Checks if the file is open by reading one character from it.
|
// Checks if the file is open by reading one character from it.
|
||||||
static bool isopen(int fd) {
|
static bool isopen(int fd) {
|
||||||
char buffer;
|
char buffer;
|
||||||
@ -119,7 +118,7 @@ TEST(BufferedFileTest, CloseFileInDtor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(BufferedFileTest, CloseErrorInDtor) {
|
TEST(BufferedFileTest, CloseErrorInDtor) {
|
||||||
scoped_ptr<buffered_file> f(new buffered_file(open_buffered_file()));
|
std::unique_ptr<buffered_file> f(new buffered_file(open_buffered_file()));
|
||||||
EXPECT_WRITE(stderr, {
|
EXPECT_WRITE(stderr, {
|
||||||
// The close function must be called inside EXPECT_WRITE, otherwise
|
// The close function must be called inside EXPECT_WRITE, otherwise
|
||||||
// the system may recycle closed file descriptor when redirecting the
|
// the system may recycle closed file descriptor when redirecting the
|
||||||
@ -246,7 +245,7 @@ TEST(FileTest, CloseFileInDtor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(FileTest, CloseErrorInDtor) {
|
TEST(FileTest, CloseErrorInDtor) {
|
||||||
scoped_ptr<file> f(new file(open_file()));
|
std::unique_ptr<file> f(new file(open_file()));
|
||||||
EXPECT_WRITE(stderr, {
|
EXPECT_WRITE(stderr, {
|
||||||
// The close function must be called inside EXPECT_WRITE, otherwise
|
// The close function must be called inside EXPECT_WRITE, otherwise
|
||||||
// the system may recycle closed file descriptor when redirecting the
|
// the system may recycle closed file descriptor when redirecting the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user