summaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@google.com>2023-03-03 23:54:32 (GMT)
committerCopybara-Service <copybara-worker@google.com>2023-03-06 15:14:21 (GMT)
commit23142843f7c875907a6ed7985174a6e346e82c3d (patch)
tree27fada6ccf3be641ec3ec564887750cf6df98d70 /googlemock
parentcead3d57c93ff8c4e5c1bbae57a5c0b0b0f6e168 (diff)
downloadgoogletest-23142843f7c875907a6ed7985174a6e346e82c3d.zip
googletest-23142843f7c875907a6ed7985174a6e346e82c3d.tar.gz
googletest-23142843f7c875907a6ed7985174a6e346e82c3d.tar.bz2
Use "#ifdef GTEST_OS_..." instead of "#if GTEST_OS_..."
This is compatible with compiling with "-Wundef" (#3267). PiperOrigin-RevId: 513943378 Change-Id: I47cf5fabbb77be061c4483a0adc54511af6b191c
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/include/gmock/gmock-actions.h4
-rw-r--r--googlemock/include/gmock/gmock-nice-strict.h2
-rw-r--r--googlemock/src/gmock-spec-builders.cc6
-rw-r--r--googlemock/src/gmock_main.cc8
-rw-r--r--googlemock/test/gmock-actions_test.cc2
-rw-r--r--googlemock/test/gmock-function-mocker_test.cc12
-rw-r--r--googlemock/test/gmock-internal-utils_test.cc4
-rw-r--r--googlemock/test/gmock_link_test.h6
8 files changed, 22 insertions, 22 deletions
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index 1cffde2..c0bb8a9 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -1273,7 +1273,7 @@ class AssignAction {
const T2 value_;
};
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
// Implements the SetErrnoAndReturn action to simulate return from
// various system calls and libc functions.
@@ -1926,7 +1926,7 @@ PolymorphicAction<internal::AssignAction<T1, T2>> Assign(T1* ptr, T2 val) {
return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
}
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
// Creates an action that sets errno and returns the appropriate error.
template <typename T>
diff --git a/googlemock/include/gmock/gmock-nice-strict.h b/googlemock/include/gmock/gmock-nice-strict.h
index 4f0eb35..056d471 100644
--- a/googlemock/include/gmock/gmock-nice-strict.h
+++ b/googlemock/include/gmock/gmock-nice-strict.h
@@ -98,7 +98,7 @@ constexpr bool HasStrictnessModifier() {
// deregistration. This guarantees that MockClass's constructor and destructor
// run with the same level of strictness as its instance methods.
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW && \
+#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW) && \
(defined(_MSC_VER) || defined(__clang__))
// We need to mark these classes with this declspec to ensure that
// the empty base class optimization is performed.
diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index a7fe911..5a98faf 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -48,10 +48,10 @@
#include "gtest/gtest.h"
#include "gtest/internal/gtest-port.h"
-#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
+#if defined(GTEST_OS_CYGWIN) || defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC)
#include <unistd.h> // NOLINT
#endif
-#if GTEST_OS_QURT
+#ifdef GTEST_OS_QURT
#include <qurt_event.h>
#endif
@@ -526,7 +526,7 @@ class MockObjectRegistry {
// RUN_ALL_TESTS() has already returned when this destructor is
// called. Therefore we cannot use the normal Google Test
// failure reporting mechanism.
-#if GTEST_OS_QURT
+#ifdef GTEST_OS_QURT
qurt_exception_raise_fatal();
#else
_exit(1); // We cannot call exit() as it is not reentrant and
diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc
index b411c5e..fb37b53 100644
--- a/googlemock/src/gmock_main.cc
+++ b/googlemock/src/gmock_main.cc
@@ -32,8 +32,8 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-#if GTEST_OS_ESP8266 || GTEST_OS_ESP32
-#if GTEST_OS_ESP8266
+#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32)
+#ifdef GTEST_OS_ESP8266
extern "C" {
#endif
void setup() {
@@ -43,7 +43,7 @@ void setup() {
testing::InitGoogleMock();
}
void loop() { RUN_ALL_TESTS(); }
-#if GTEST_OS_ESP8266
+#ifdef GTEST_OS_ESP8266
}
#endif
@@ -55,7 +55,7 @@ void loop() { RUN_ALL_TESTS(); }
// Windows. See the following link to track the current status of this bug:
// https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
// // NOLINT
-#if GTEST_OS_WINDOWS_MOBILE
+#ifdef GTEST_OS_WINDOWS_MOBILE
#include <tchar.h> // NOLINT
GTEST_API_ int _tmain(int argc, TCHAR** argv) {
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index f2d3042..7734830 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -1592,7 +1592,7 @@ TEST(WithArgsTest, RefQualifiedInnerAction) {
EXPECT_EQ(19, mock.AsStdFunction()(0, 17));
}
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
class SetErrnoAndReturnTest : public testing::Test {
protected:
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc
index e211aff..4db498d 100644
--- a/googlemock/test/gmock-function-mocker_test.cc
+++ b/googlemock/test/gmock-function-mocker_test.cc
@@ -35,7 +35,7 @@
// Silence C4503 (decorated name length exceeded) for MSVC.
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4503)
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
// we are getting compiler errors if we use basetyps.h, hence including
// objbase.h for definition of STDMETHOD.
@@ -120,7 +120,7 @@ class FooInterface {
virtual int RefQualifiedOverloaded() & = 0;
virtual int RefQualifiedOverloaded() && = 0;
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
STDMETHOD_(int, CTNullary)() = 0;
STDMETHOD_(bool, CTUnary)(int x) = 0;
STDMETHOD_(int, CTDecimal)
@@ -178,7 +178,7 @@ class MockFoo : public FooInterface {
MOCK_METHOD(int (*)(bool), ReturnsFunctionPointer1, (int), ());
MOCK_METHOD(fn_ptr, ReturnsFunctionPointer2, (int), ());
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE)));
MOCK_METHOD(bool, CTUnary, (int), (Calltype(STDMETHODCALLTYPE)));
MOCK_METHOD(int, CTDecimal,
@@ -248,7 +248,7 @@ class LegacyMockFoo : public FooInterface {
MOCK_METHOD1(ReturnsFunctionPointer1, int (*(int))(bool));
MOCK_METHOD1(ReturnsFunctionPointer2, fn_ptr(int));
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int());
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int)); // NOLINT
MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal,
@@ -404,7 +404,7 @@ TYPED_TEST(FunctionMockerTest, MocksTypeWithTemplatedCopyCtor) {
EXPECT_TRUE(this->foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable<int>()));
}
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
// Tests mocking a nullary function with calltype.
TYPED_TEST(FunctionMockerTest, MocksNullaryFunctionWithCallType) {
EXPECT_CALL(this->mock_foo_, CTNullary())
@@ -620,7 +620,7 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
}
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
// Tests mocking template interfaces with calltype.
template <typename T>
diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc
index 932bece..360d02a 100644
--- a/googlemock/test/gmock-internal-utils_test.cc
+++ b/googlemock/test/gmock-internal-utils_test.cc
@@ -56,7 +56,7 @@
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
-#if GTEST_OS_CYGWIN
+#ifdef GTEST_OS_CYGWIN
#include <sys/types.h> // For ssize_t. NOLINT
#endif
@@ -167,7 +167,7 @@ TEST(KindOfTest, Integer) {
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long long)); // NOLINT
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t)); // NOLINT
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t)); // NOLINT
-#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN
+#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || defined(GTEST_OS_CYGWIN)
// ssize_t is not defined on Windows and possibly some other OSes.
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(ssize_t)); // NOLINT
#endif
diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h
index 95a8cb8..8d2abb1 100644
--- a/googlemock/test/gmock_link_test.h
+++ b/googlemock/test/gmock_link_test.h
@@ -116,7 +116,7 @@
#include "gmock/gmock.h"
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
#include <errno.h>
#endif
@@ -181,7 +181,7 @@ using testing::WithArg;
using testing::WithArgs;
using testing::WithoutArgs;
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
using testing::SetErrnoAndReturn;
#endif
@@ -306,7 +306,7 @@ TEST(LinkTest, TestSetArrayArgument) {
mock.VoidFromString(&ch);
}
-#if !GTEST_OS_WINDOWS_MOBILE
+#ifndef GTEST_OS_WINDOWS_MOBILE
// Tests the linkage of the SetErrnoAndReturn action.
TEST(LinkTest, TestSetErrnoAndReturn) {