mirror of
https://github.com/google/googletest.git
synced 2026-07-30 08:16:27 +08:00
Fix broken tests due to deprecation warning
PiperOrigin-RevId: 951523081 Change-Id: I145c6066a202629e5d0c89453d726495dd535290
This commit is contained in:
parent
fa005b296f
commit
30a3151b0c
@ -1222,23 +1222,26 @@ class Foo {
|
||||
|
||||
// Tests InvokeWithoutArgs(function).
|
||||
TEST(InvokeWithoutArgsTest, Function) {
|
||||
GTEST_DISABLE_DEPRECATED_PUSH_()
|
||||
// As an action that takes one argument.
|
||||
Action<int(int)> a = Nullary; // NOLINT
|
||||
Action<int(int)> a = InvokeWithoutArgs(Nullary); // NOLINT
|
||||
EXPECT_EQ(1, a.Perform(std::make_tuple(2)));
|
||||
|
||||
// As an action that takes two arguments.
|
||||
Action<int(int, double)> a2 = Nullary; // NOLINT
|
||||
Action<int(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT
|
||||
EXPECT_EQ(1, a2.Perform(std::make_tuple(2, 3.5)));
|
||||
|
||||
// As an action that returns void.
|
||||
Action<void(int)> a3 = VoidNullary; // NOLINT
|
||||
Action<void(int)> a3 = InvokeWithoutArgs(VoidNullary); // NOLINT
|
||||
g_done = false;
|
||||
a3.Perform(std::make_tuple(1));
|
||||
EXPECT_TRUE(g_done);
|
||||
GTEST_DISABLE_DEPRECATED_POP_()
|
||||
}
|
||||
|
||||
// Tests InvokeWithoutArgs(functor).
|
||||
TEST(InvokeWithoutArgsTest, Functor) {
|
||||
GTEST_DISABLE_DEPRECATED_PUSH_()
|
||||
// As an action that takes no argument.
|
||||
Action<int()> a = InvokeWithoutArgs(NullaryFunctor()); // NOLINT
|
||||
EXPECT_EQ(2, a.Perform(std::make_tuple()));
|
||||
@ -1253,6 +1256,7 @@ TEST(InvokeWithoutArgsTest, Functor) {
|
||||
g_done = false;
|
||||
a3.Perform(std::make_tuple());
|
||||
EXPECT_TRUE(g_done);
|
||||
GTEST_DISABLE_DEPRECATED_POP_()
|
||||
}
|
||||
|
||||
// Tests InvokeWithoutArgs(obj_ptr, method).
|
||||
|
||||
@ -338,10 +338,12 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
|
||||
Mock mock;
|
||||
InvokeHelper test_invoke_helper;
|
||||
|
||||
GTEST_DISABLE_DEPRECATED_PUSH_()
|
||||
EXPECT_CALL(mock, VoidFromString(_))
|
||||
.WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
|
||||
.WillOnce(
|
||||
InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid));
|
||||
GTEST_DISABLE_DEPRECATED_POP_()
|
||||
mock.VoidFromString(nullptr);
|
||||
mock.VoidFromString(nullptr);
|
||||
}
|
||||
|
||||
@ -363,18 +363,24 @@
|
||||
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#endif
|
||||
|
||||
// Clang on Windows does not understand MSVC's pragma warning.
|
||||
// We need clang-specific way to disable function deprecation warning.
|
||||
#ifdef __clang__
|
||||
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
|
||||
// Pragmas to disable function deprecation warnings.
|
||||
#if defined(__clang__)
|
||||
#define GTEST_DISABLE_DEPRECATED_PUSH_() \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
|
||||
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
|
||||
#define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
|
||||
#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
|
||||
#elif defined(__GNUC__)
|
||||
#define GTEST_DISABLE_DEPRECATED_PUSH_() \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
|
||||
#elif defined(_MSC_VER)
|
||||
#define GTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
|
||||
#define GTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#else
|
||||
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
|
||||
#define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#define GTEST_DISABLE_DEPRECATED_PUSH_()
|
||||
#define GTEST_DISABLE_DEPRECATED_POP_()
|
||||
#endif
|
||||
|
||||
// Brings in definitions for functions used in the testing::internal::posix
|
||||
@ -2119,7 +2125,7 @@ inline int IsATTY(int fd) {
|
||||
|
||||
// Functions deprecated by MSVC 8.0.
|
||||
|
||||
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
|
||||
GTEST_DISABLE_DEPRECATED_PUSH_()
|
||||
|
||||
// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
|
||||
// StrError() aren't needed on Windows CE at this time and thus not
|
||||
@ -2181,7 +2187,7 @@ inline const char* GetEnv(const char* name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
GTEST_DISABLE_MSC_DEPRECATED_POP_()
|
||||
GTEST_DISABLE_DEPRECATED_POP_()
|
||||
|
||||
#ifdef GTEST_OS_WINDOWS_MOBILE
|
||||
// Windows CE has no C library. The abort() function is used in
|
||||
|
||||
@ -1069,7 +1069,7 @@ GTestLog::~GTestLog() {
|
||||
|
||||
// Disable Microsoft deprecation warnings for POSIX functions called from
|
||||
// this class (creat, dup, dup2, and close)
|
||||
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
|
||||
GTEST_DISABLE_DEPRECATED_PUSH_()
|
||||
|
||||
namespace {
|
||||
|
||||
@ -1200,7 +1200,7 @@ class CapturedStream {
|
||||
CapturedStream& operator=(const CapturedStream&) = delete;
|
||||
};
|
||||
|
||||
GTEST_DISABLE_MSC_DEPRECATED_POP_()
|
||||
GTEST_DISABLE_DEPRECATED_POP_()
|
||||
|
||||
static CapturedStream* g_captured_stderr = nullptr;
|
||||
static CapturedStream* g_captured_stdout = nullptr;
|
||||
|
||||
@ -442,11 +442,11 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
|
||||
void SetUp() override {
|
||||
saved_tz_.reset();
|
||||
|
||||
GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv: deprecated */)
|
||||
GTEST_DISABLE_DEPRECATED_PUSH_(/* getenv: deprecated */)
|
||||
if (const char* tz = getenv("TZ")) {
|
||||
saved_tz_ = std::make_unique<std::string>(tz);
|
||||
}
|
||||
GTEST_DISABLE_MSC_DEPRECATED_POP_()
|
||||
GTEST_DISABLE_DEPRECATED_POP_()
|
||||
|
||||
// Set the local time zone for FormatEpochTimeInMillisAsIso8601 to be
|
||||
// a fixed time zone for reproducibility purposes.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user