From f7af24c7de14ccb10a24909a6f3440a763cb1164 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Thu, 24 Sep 2009 21:17:24 +0000 Subject: [PATCH] Simplifies gmock code using gtest's OS-indicating macros. --- include/gmock/gmock-actions.h | 8 ++++---- src/gmock-printers.cc | 4 ++-- src/gmock_main.cc | 4 ++-- test/gmock-actions_test.cc | 8 ++++---- test/gmock_link_test.h | 14 +++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/gmock/gmock-actions.h b/include/gmock/gmock-actions.h index c8edc8ab..f7daf826 100644 --- a/include/gmock/gmock-actions.h +++ b/include/gmock/gmock-actions.h @@ -606,7 +606,7 @@ class AssignAction { const T2 value_; }; -#ifndef _WIN32_WCE +#if !GTEST_OS_WINDOWS_MOBILE // Implements the SetErrnoAndReturn action to simulate return from // various system calls and libc functions. @@ -626,7 +626,7 @@ class SetErrnoAndReturnAction { const T result_; }; -#endif // _WIN32_WCE +#endif // !GTEST_OS_WINDOWS_MOBILE // Implements the SetArgumentPointee(x) action for any function // whose N-th argument (0-based) is a pointer to x's type. The @@ -912,7 +912,7 @@ PolymorphicAction > Assign(T1* ptr, T2 val) { return MakePolymorphicAction(internal::AssignAction(ptr, val)); } -#ifndef _WIN32_WCE +#if !GTEST_OS_WINDOWS_MOBILE // Creates an action that sets errno and returns the appropriate error. template @@ -922,7 +922,7 @@ SetErrnoAndReturn(int errval, T result) { internal::SetErrnoAndReturnAction(errval, result)); } -#endif // _WIN32_WCE +#endif // !GTEST_OS_WINDOWS_MOBILE // Various overloads for InvokeWithoutArgs(). diff --git a/src/gmock-printers.cc b/src/gmock-printers.cc index 0473dba1..8efba782 100644 --- a/src/gmock-printers.cc +++ b/src/gmock-printers.cc @@ -55,13 +55,13 @@ namespace { using ::std::ostream; -#ifdef _WIN32_WCE // Windows CE does not define _snprintf_s. +#if GTEST_OS_WINDOWS_MOBILE // Windows CE does not define _snprintf_s. #define snprintf _snprintf #elif _MSC_VER >= 1400 // VC 8.0 and later deprecate snprintf and _snprintf. #define snprintf _snprintf_s #elif _MSC_VER #define snprintf _snprintf -#endif +#endif // GTEST_OS_WINDOWS_MOBILE // Prints a segment of bytes in the given object. void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start, diff --git a/src/gmock_main.cc b/src/gmock_main.cc index 85689d5d..0a3071bf 100644 --- a/src/gmock_main.cc +++ b/src/gmock_main.cc @@ -38,13 +38,13 @@ // is enabled. For this reason instead of _tmain, main function is used on // Windows. See the following link to track the current status of this bug: // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=394464 // NOLINT -#ifdef _WIN32_WCE +#if GTEST_OS_WINDOWS_MOBILE #include // NOLINT int _tmain(int argc, TCHAR** argv) { #else int main(int argc, char** argv) { -#endif // _WIN32_WCE +#endif // GTEST_OS_WINDOWS_MOBILE std::cout << "Running main() from gmock_main.cc\n"; // Since Google Mock depends on Google Test, InitGoogleMock() is // also responsible for initializing Google Test. Therefore there's diff --git a/test/gmock-actions_test.cc b/test/gmock-actions_test.cc index 772f0605..5d05bc50 100644 --- a/test/gmock-actions_test.cc +++ b/test/gmock-actions_test.cc @@ -70,9 +70,9 @@ using testing::ReturnNull; using testing::ReturnRef; using testing::SetArgumentPointee; -#ifndef _WIN32_WCE +#if !GTEST_OS_WINDOWS_MOBILE using testing::SetErrnoAndReturn; -#endif // _WIN32_WCE +#endif #if GMOCK_HAS_PROTOBUF_ using testing::internal::TestMessage; @@ -911,7 +911,7 @@ TEST(AssignTest, CompatibleTypes) { EXPECT_DOUBLE_EQ(5, x); } -#ifndef _WIN32_WCE +#if !GTEST_OS_WINDOWS_MOBILE class SetErrnoAndReturnTest : public testing::Test { protected: @@ -938,7 +938,7 @@ TEST_F(SetErrnoAndReturnTest, CompatibleTypes) { EXPECT_EQ(EINVAL, errno); } -#endif // _WIN32_WCE +#endif // !GTEST_OS_WINDOWS_MOBILE // Tests ByRef(). diff --git a/test/gmock_link_test.h b/test/gmock_link_test.h index b903f3cb..bbac8ae2 100644 --- a/test/gmock_link_test.h +++ b/test/gmock_link_test.h @@ -116,7 +116,7 @@ #include -#ifndef _WIN32_WCE +#if !GTEST_OS_WINDOWS_MOBILE #include #endif @@ -176,18 +176,18 @@ using testing::WithArg; using testing::WithArgs; using testing::WithoutArgs; -#ifndef _WIN32_WCE +#if !GTEST_OS_WINDOWS_MOBILE using testing::SetErrnoAndReturn; -#endif // _WIN32_WCE +#endif #if GTEST_HAS_EXCEPTIONS using testing::Throw; -#endif // GTEST_HAS_EXCEPTIONS +#endif #if GMOCK_HAS_REGEX using testing::ContainsRegex; using testing::MatchesRegex; -#endif // GMOCK_HAS_REGEX +#endif class Interface { public: @@ -297,7 +297,7 @@ TEST(LinkTest, TestSetArrayArgument) { mock.VoidFromString(&ch); } -#ifndef _WIN32_WCE +#if !GTEST_OS_WINDOWS_MOBILE // Tests the linkage of the SetErrnoAndReturn action. TEST(LinkTest, TestSetErrnoAndReturn) { @@ -309,7 +309,7 @@ TEST(LinkTest, TestSetErrnoAndReturn) { errno = saved_errno; } -#endif // _WIN32_WCE +#endif // !GTEST_OS_WINDOWS_MOBILE // Tests the linkage of the Invoke(function) and Invoke(object, method) actions. TEST(LinkTest, TestInvoke) {