From 88fc7d7552ead9d9c224b06bf0d2c1f17e21d612 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 09:50:01 -0400 Subject: [PATCH 01/32] merging gmock-actions 2 --- googlemock/include/gmock/gmock-actions.h | 90 +++++++++++--- googlemock/test/gmock-actions_test.cc | 144 ++++++++++++++++++++++- 2 files changed, 216 insertions(+), 18 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 90fd2ea6..a2784f63 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -360,15 +360,21 @@ class Action { // Constructs a null Action. Needed for storing Action objects in // STL containers. - Action() : impl_(NULL) {} + Action() {} - // Constructs an Action from its implementation. A NULL impl is - // used to represent the "do-default" action. +#if GTEST_LANG_CXX11 + // Construct an Action from a specified callable. + // This cannot take std::function directly, because then Action would not be + // directly constructible from lambda (it would require two conversions). + template , G>::value>::type> + Action(G&& fun) : fun_(::std::forward(fun)) {} // NOLINT +#endif + + // Constructs an Action from its implementation. explicit Action(ActionInterface* impl) : impl_(impl) {} - // Copy constructor. - Action(const Action& action) : impl_(action.impl_) {} - // This constructor allows us to turn an Action object into an // Action, as long as F's arguments can be implicitly converted // to Func's and Func's return type can be implicitly converted to @@ -377,7 +383,13 @@ class Action { explicit Action(const Action& action); // Returns true iff this is the DoDefault() action. - bool IsDoDefault() const { return impl_.get() == NULL; } + bool IsDoDefault() const { +#if GTEST_LANG_CXX11 + return impl_ == nullptr && fun_ == nullptr; +#else + return impl_ == NULL; +#endif + } // Performs the action. Note that this method is const even though // the corresponding method in ActionInterface is not. The reason @@ -385,14 +397,15 @@ class Action { // another concrete action, not that the concrete action it binds to // cannot change state. (Think of the difference between a const // pointer and a pointer to const.) - Result Perform(const ArgumentTuple& args) const { - internal::Assert( - !IsDoDefault(), __FILE__, __LINE__, - "You are using DoDefault() inside a composite action like " - "DoAll() or WithArgs(). This is not supported for technical " - "reasons. Please instead spell out the default action, or " - "assign the default action to an Action variable and use " - "the variable in various places."); + Result Perform(ArgumentTuple args) const { + if (IsDoDefault()) { + internal::IllegalDoDefault(__FILE__, __LINE__); + } +#if GTEST_LANG_CXX11 + if (fun_ != nullptr) { + return internal::Apply(fun_, ::std::move(args)); + } +#endif return impl_->Perform(args); } @@ -400,6 +413,18 @@ class Action { template friend class internal::ActionAdaptor; + template + friend class Action; + + // In C++11, Action can be implemented either as a generic functor (through + // std::function), or legacy ActionInterface. In C++98, only ActionInterface + // is available. The invariants are as follows: + // * in C++98, impl_ is null iff this is the default action + // * in C++11, at most one of fun_ & impl_ may be nonnull; both are null iff + // this is the default action +#if GTEST_LANG_CXX11 + ::std::function fun_; +#endif internal::linked_ptr > impl_; }; @@ -531,6 +556,9 @@ struct ByMoveWrapper { // statement, and conversion of the result of Return to Action is a // good place for that. // +// The real life example of the above scenario happens when an invocation +// of gtl::Container() is passed into Return. +// template class ReturnAction { public: @@ -750,7 +778,7 @@ class DoDefaultAction { // This template type conversion operator allows DoDefault() to be // used in any function. template - operator Action() const { return Action(NULL); } + operator Action() const { return Action(); } // NOLINT }; // Implements the Assign action to set a given pointer referent to a @@ -886,6 +914,28 @@ class InvokeMethodWithoutArgsAction { GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction); }; +// Implements the InvokeWithoutArgs(callback) action. +template +class InvokeCallbackWithoutArgsAction { + public: + // The c'tor takes ownership of the callback. + explicit InvokeCallbackWithoutArgsAction(CallbackType* callback) + : callback_(callback) { + callback->CheckIsRepeatable(); // Makes sure the callback is permanent. + } + + // This type conversion operator template allows Invoke(callback) to + // be used wherever the callback's return type can be implicitly + // converted to that of the mock function. + template + Result Perform(const ArgumentTuple&) const { return callback_->Run(); } + + private: + const internal::linked_ptr callback_; + + GTEST_DISALLOW_ASSIGN_(InvokeCallbackWithoutArgsAction); +}; + // Implements the IgnoreResult(action) action. template class IgnoreResultAction { @@ -1053,7 +1103,13 @@ typedef internal::IgnoredValue Unused; template template Action::Action(const Action& from) - : impl_(new internal::ActionAdaptor(from)) {} + : +#if GTEST_LANG_CXX11 + fun_(from.fun_), +#endif + impl_(from.impl_ == NULL ? NULL + : new internal::ActionAdaptor(from)) { +} // Creates an action that returns 'value'. 'value' is passed by value // instead of const reference - otherwise Return("string literal") diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 46011570..ea6129d7 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -65,6 +65,7 @@ using testing::ReturnRef; using testing::ReturnRefOfCopy; using testing::SetArgPointee; using testing::SetArgumentPointee; +using testing::Unused; using testing::_; using testing::get; using testing::internal::BuiltInDefaultValue; @@ -705,6 +706,8 @@ class MockClass { MOCK_METHOD0(MakeUniqueBase, std::unique_ptr()); MOCK_METHOD0(MakeVectorUnique, std::vector>()); MOCK_METHOD1(TakeUnique, int(std::unique_ptr)); + MOCK_METHOD2(TakeUnique, + int(const std::unique_ptr&, std::unique_ptr)); #endif private: @@ -756,7 +759,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) { } // Tests that DoDefault() returns the default value set by -// DefaultValue::Set() when it's not overridden by an ON_CALL(). +// DefaultValue::Set() when it's not overriden by an ON_CALL(). TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) { DefaultValue::Set(1); MockClass mock; @@ -1411,6 +1414,145 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { EXPECT_EQ(7, *vresult[0]); } +TEST(MockMethodTest, CanTakeMoveOnlyValue) { + MockClass mock; + auto make = [](int i) { return std::unique_ptr(new int(i)); }; + + EXPECT_CALL(mock, TakeUnique(_)).WillRepeatedly([](std::unique_ptr i) { + return *i; + }); + // DoAll() does not compile, since it would move from its arguments twice. + // EXPECT_CALL(mock, TakeUnique(_, _)) + // .WillRepeatedly(DoAll(Invoke([](std::unique_ptr j) {}), + // Return(1))); + EXPECT_CALL(mock, TakeUnique(testing::Pointee(7))) + .WillOnce(Return(-7)) + .RetiresOnSaturation(); + EXPECT_CALL(mock, TakeUnique(testing::IsNull())) + .WillOnce(Return(-1)) + .RetiresOnSaturation(); + + EXPECT_EQ(5, mock.TakeUnique(make(5))); + EXPECT_EQ(-7, mock.TakeUnique(make(7))); + EXPECT_EQ(7, mock.TakeUnique(make(7))); + EXPECT_EQ(7, mock.TakeUnique(make(7))); + EXPECT_EQ(-1, mock.TakeUnique({})); + + // Some arguments are moved, some passed by reference. + auto lvalue = make(6); + EXPECT_CALL(mock, TakeUnique(_, _)) + .WillOnce([](const std::unique_ptr& i, std::unique_ptr j) { + return *i * *j; + }); + EXPECT_EQ(42, mock.TakeUnique(lvalue, make(7))); + + // The unique_ptr can be saved by the action. + std::unique_ptr saved; + EXPECT_CALL(mock, TakeUnique(_)).WillOnce([&saved](std::unique_ptr i) { + saved = std::move(i); + return 0; + }); + EXPECT_EQ(0, mock.TakeUnique(make(42))); + EXPECT_EQ(42, *saved); +} + #endif // GTEST_HAS_STD_UNIQUE_PTR_ +#if GTEST_LANG_CXX11 +// Tests for std::function based action. + +int Add(int val, int& ref, int* ptr) { // NOLINT + int result = val + ref + *ptr; + ref = 42; + *ptr = 43; + return result; +} + +int Deref(std::unique_ptr ptr) { return *ptr; } + +struct Double { + template + T operator()(T t) { return 2 * t; } +}; + +std::unique_ptr UniqueInt(int i) { + return std::unique_ptr(new int(i)); +} + +TEST(FunctorActionTest, ActionFromFunction) { + Action a = &Add; + int x = 1, y = 2, z = 3; + EXPECT_EQ(6, a.Perform(std::forward_as_tuple(x, y, &z))); + EXPECT_EQ(42, y); + EXPECT_EQ(43, z); + + Action)> a1 = &Deref; + EXPECT_EQ(7, a1.Perform(std::make_tuple(UniqueInt(7)))); +} + +TEST(FunctorActionTest, ActionFromLambda) { + Action a1 = [](bool b, int i) { return b ? i : 0; }; + EXPECT_EQ(5, a1.Perform(make_tuple(true, 5))); + EXPECT_EQ(0, a1.Perform(make_tuple(false, 5))); + + std::unique_ptr saved; + Action)> a2 = [&saved](std::unique_ptr p) { + saved = std::move(p); + }; + a2.Perform(make_tuple(UniqueInt(5))); + EXPECT_EQ(5, *saved); +} + +TEST(FunctorActionTest, PolymorphicFunctor) { + Action ai = Double(); + EXPECT_EQ(2, ai.Perform(make_tuple(1))); + Action ad = Double(); // Double? Double double! + EXPECT_EQ(3.0, ad.Perform(make_tuple(1.5))); +} + +TEST(FunctorActionTest, TypeConversion) { + // Numeric promotions are allowed. + const Action a1 = [](int i) { return i > 1; }; + const Action a2 = Action(a1); + EXPECT_EQ(1, a1.Perform(make_tuple(42))); + EXPECT_EQ(0, a2.Perform(make_tuple(42))); + + // Implicit constructors are allowed. + const Action s1 = [](std::string s) { return !s.empty(); }; + const Action s2 = Action(s1); + EXPECT_EQ(0, s2.Perform(make_tuple(""))); + EXPECT_EQ(1, s2.Perform(make_tuple("hello"))); + + // Also between the lambda and the action itself. + const Action x = [](Unused) { return 42; }; + EXPECT_TRUE(x.Perform(make_tuple("hello"))); +} + +TEST(FunctorActionTest, UnusedArguments) { + // Verify that users can ignore uninteresting arguments. + Action, const int&)> a = + [](int i, Unused, Unused) { return 2 * i; }; + EXPECT_EQ(6, a.Perform(make_tuple(3, UniqueInt(7), 9))); +} + +// Test that basic built-in actions work with move-only arguments. +// TODO(rburny): Currently, almost all ActionInterface-based actions will not +// work, even if they only try to use other, copyable arguments. Implement them +// if necessary (but note that DoAll cannot work on non-copyable types anyway - +// so maybe it's better to make users use lambdas instead. +TEST(MoveOnlyArgumentsTest, ReturningActions) { + Action)> a = Return(1); + EXPECT_EQ(1, a.Perform(make_tuple(nullptr))); + + a = testing::WithoutArgs([]() { return 7; }); + EXPECT_EQ(7, a.Perform(make_tuple(nullptr))); + + Action, int*)> a2 = testing::SetArgPointee<1>(3); + int x = 0; + a2.Perform(make_tuple(nullptr, &x)); + EXPECT_EQ(x, 3); +} + +#endif // GTEST_LANG_CXX11 + } // Unnamed namespace From b5c87fbcb6b708026bc83c01e38a43691c9064a0 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 10:01:40 -0400 Subject: [PATCH 02/32] Deal with MCVS warnings --- googlemock/include/gmock/internal/gmock-internal-utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 37ceb549..030a1d61 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -48,6 +48,12 @@ namespace testing { namespace internal { +// Silence C4100 (unreferenced formal +// parameter) for MSVC +#ifdef _MSC_VER +# pragma warning(disable:4100) +#endif + // Joins a vector of strings as if they are fields of a tuple; returns // the joined string. GTEST_API_ std::string JoinAsTuple(const Strings& fields); From 50c0bcd7e36374d6c3d0359c2160d8493e67527e Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 10:15:00 -0400 Subject: [PATCH 03/32] Cont. deal with MCVS warnings --- googlemock/include/gmock/gmock-more-matchers.h | 6 ++++++ .../include/gmock/internal/gmock-internal-utils.h | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/googlemock/include/gmock/gmock-more-matchers.h b/googlemock/include/gmock/gmock-more-matchers.h index 01298cfa..4c248325 100644 --- a/googlemock/include/gmock/gmock-more-matchers.h +++ b/googlemock/include/gmock/gmock-more-matchers.h @@ -46,6 +46,7 @@ namespace testing { // Silence C4100 (unreferenced formal // parameter) for MSVC #ifdef _MSC_VER +# pragma warning(push) # pragma warning(disable:4100) #if (_MSC_VER == 1900) # pragma warning(disable:4800) @@ -78,6 +79,11 @@ MATCHER(IsFalse, negation ? "is true" : "is false") { return !static_cast(arg); } +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + } // namespace testing #endif // GMOCK_GMOCK_MORE_MATCHERS_H_ diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 030a1d61..85becb5f 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -48,10 +48,12 @@ namespace testing { namespace internal { -// Silence C4100 (unreferenced formal -// parameter) for MSVC +// Silence MSVC C4100 (unreferenced formal parameter) and +// C4805('==': unsafe mix of type 'const int' and type 'const bool') #ifdef _MSC_VER +# pragma warning(push) # pragma warning(disable:4100) +# pragma warning(disable:C4805) #endif // Joins a vector of strings as if they are fields of a tuple; returns @@ -545,6 +547,12 @@ auto Apply(F&& f, Tuple&& args) make_int_pack::value>()); } #endif + + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + } // namespace internal } // namespace testing From eb3e4aac2e7f740a207f2bb3207cb925b9270c0e Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 10:24:49 -0400 Subject: [PATCH 04/32] deal with MSVC warn, cont 1 --- googlemock/include/gmock/internal/gmock-internal-utils.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 85becb5f..29b69926 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -52,8 +52,7 @@ namespace internal { // C4805('==': unsafe mix of type 'const int' and type 'const bool') #ifdef _MSC_VER # pragma warning(push) -# pragma warning(disable:4100) -# pragma warning(disable:C4805) +# pragma warning(disable: 4100 C4805) #endif // Joins a vector of strings as if they are fields of a tuple; returns From 1831ac93611ab478e8bbaf0f6ce8048fd9560835 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 10:35:09 -0400 Subject: [PATCH 05/32] more warnings --- googlemock/include/gmock/internal/gmock-internal-utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 29b69926..76df2e57 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -52,7 +52,7 @@ namespace internal { // C4805('==': unsafe mix of type 'const int' and type 'const bool') #ifdef _MSC_VER # pragma warning(push) -# pragma warning(disable: 4100 C4805) +# pragma warning(disable: 4100, C4805) #endif // Joins a vector of strings as if they are fields of a tuple; returns From 32ac9492544cf099859492038093cd5819056946 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 10:43:11 -0400 Subject: [PATCH 06/32] cont --- googlemock/include/gmock/internal/gmock-internal-utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 76df2e57..7f761344 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -52,7 +52,7 @@ namespace internal { // C4805('==': unsafe mix of type 'const int' and type 'const bool') #ifdef _MSC_VER # pragma warning(push) -# pragma warning(disable: 4100, C4805) +# pragma warning(disable: 4100 4805;) #endif // Joins a vector of strings as if they are fields of a tuple; returns From 04e31881fcc21a23b552584062b672055fb288c0 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 10:52:49 -0400 Subject: [PATCH 07/32] cont - 2 --- googlemock/include/gmock/internal/gmock-internal-utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 7f761344..00c6cc39 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -52,7 +52,7 @@ namespace internal { // C4805('==': unsafe mix of type 'const int' and type 'const bool') #ifdef _MSC_VER # pragma warning(push) -# pragma warning(disable: 4100 4805;) +# pragma warning(disable:4100 4805;) #endif // Joins a vector of strings as if they are fields of a tuple; returns From c75b76e20ae06e506ef72a3339208f14fd376493 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 11:00:13 -0400 Subject: [PATCH 08/32] warnings --- googlemock/include/gmock/internal/gmock-internal-utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 00c6cc39..ef150e0f 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -52,7 +52,8 @@ namespace internal { // C4805('==': unsafe mix of type 'const int' and type 'const bool') #ifdef _MSC_VER # pragma warning(push) -# pragma warning(disable:4100 4805;) +# pragma warning(disable:4100) +# pragma warning(disable:4805) #endif // Joins a vector of strings as if they are fields of a tuple; returns From d9f3611a227cf51eb8028b07e58ba330d3a04092 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 11:17:45 -0400 Subject: [PATCH 09/32] more MSVC warnings --- googletest/include/gtest/gtest.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 26e787d9..3de5fca4 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -82,6 +82,13 @@ namespace testing { +// Silence C4100 (unreferenced formal parameter) for MSVC +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4100) +#endif + + // Declares the flags. // This flag temporary enables the disabled tests. @@ -2298,6 +2305,10 @@ bool StaticAssertTypeEq() { // Tries to determine an appropriate directory for the platform. GTEST_API_ std::string TempDir(); +#ifdef _MSC_VER +# pragma warning(pop) +#endif + } // namespace testing // Use this function in main() to run all tests. It returns 0 if all From cb13dc759c4697becda3b2ede7f3ba3e5c2765f2 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 11:26:12 -0400 Subject: [PATCH 10/32] more warnings --- googletest/include/gtest/gtest.h | 1 + 1 file changed, 1 insertion(+) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 3de5fca4..cbab121a 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -86,6 +86,7 @@ namespace testing { #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable:4100) +# pragma warning(disable:4805) #endif From 5fe8de5ded685541a63b0ac22b1cfb4c59406dfd Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 11:40:04 -0400 Subject: [PATCH 11/32] more warnings --- googlemock/test/gmock_output_test_.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index ca628df6..d5f909d9 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -39,6 +39,14 @@ #include "gtest/gtest.h" + +// Silence C4100 (unreferenced formal parameter) for MSVC +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4100) +#endif + + using testing::_; using testing::AnyNumber; using testing::Ge; @@ -298,3 +306,7 @@ int main(int argc, char **argv) { TestCatchesLeakedMocksInAdHocTests(); return RUN_ALL_TESTS(); } + +#ifdef _MSC_VER +# pragma warning(pop) +#endif From 2d4d4ef7392bc577449ade669b282853cb7adb39 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 16:31:11 -0400 Subject: [PATCH 12/32] fixing MSVC --- googlemock/include/gmock/gmock-more-matchers.h | 2 ++ googlemock/src/gmock-internal-utils.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/googlemock/include/gmock/gmock-more-matchers.h b/googlemock/include/gmock/gmock-more-matchers.h index 4c248325..6d810eb7 100644 --- a/googlemock/include/gmock/gmock-more-matchers.h +++ b/googlemock/include/gmock/gmock-more-matchers.h @@ -49,6 +49,8 @@ namespace testing { # pragma warning(push) # pragma warning(disable:4100) #if (_MSC_VER == 1900) +// and silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 14 # pragma warning(disable:4800) #endif #endif diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index 20c5a8db..3fca3f26 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -188,7 +188,7 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message, std::cout << ::std::flush; } -void IllegalDoDefault(const char* file, int line) { +GTEST_API_ void IllegalDoDefault(const char* file, int line) { internal::Assert( false, file, line, "You are using DoDefault() inside a composite action like " From 701e1e5dc1ccd25e7a55891d2dd6b4edb8f1f442 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 16:43:35 -0400 Subject: [PATCH 13/32] linkage, fixing MSVC --- googlemock/include/gmock/internal/gmock-internal-utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index ef150e0f..20c95c6a 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -518,7 +518,7 @@ struct BooleanConstant {}; // Emit an assertion failure due to incorrect DoDefault() usage. Out-of-lined to // reduce code size. -void IllegalDoDefault(const char* file, int line); +GTEST_API_ void IllegalDoDefault(const char* file, int line); #if GTEST_LANG_CXX11 // Helper types for Apply() below. From dbd206e3d9aecf4a0abe11e051b71a098252c9d2 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 6 Apr 2018 16:55:46 -0400 Subject: [PATCH 14/32] more mcvs fixing --- googlemock/src/gmock-spec-builders.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index b97bad03..39a3fe74 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -49,6 +49,14 @@ # include // NOLINT #endif +// Silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 14 +#ifdef _MSC_VER && _MSC_VER == 1900 +# pragma warning(push) +# pragma warning(disable:4800) +#endif + + namespace testing { namespace internal { @@ -866,3 +874,7 @@ InSequence::~InSequence() { } } // namespace testing + +#ifdef _MSC_VER && _MSC_VER == 1900 +# pragma warning(pop) +#endif From e0b3c269c23e152ed44e0f4db585319e4e5d5630 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 09:51:02 -0400 Subject: [PATCH 15/32] continued --- googlemock/include/gmock/gmock-generated-actions.h | 4 +++- googlemock/include/gmock/gmock-generated-actions.h.pump | 2 +- googlemock/include/gmock/gmock-generated-matchers.h.pump | 4 ++-- googlemock/include/gmock/gmock-generated-nice-strict.h.pump | 4 ++-- googlemock/src/gmock-spec-builders.cc | 1 - 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h index be4ebe4f..b35303e2 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h +++ b/googlemock/include/gmock/gmock-generated-actions.h @@ -1,4 +1,6 @@ -// This file was GENERATED by a script. DO NOT EDIT BY HAND!!! +// This file was GENERATED by command: +// pump.py gmock-generated-actions.h.pump +// DO NOT EDIT BY HAND!!! // Copyright 2007, Google Inc. // All rights reserved. diff --git a/googlemock/include/gmock/gmock-generated-actions.h.pump b/googlemock/include/gmock/gmock-generated-actions.h.pump index 712f65d6..e0c21359 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h.pump +++ b/googlemock/include/gmock/gmock-generated-actions.h.pump @@ -1,5 +1,5 @@ $$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert it to +$$ This is a Pump source file. Please use Pump to convert it to $$ gmock-generated-actions.h. $$ $var n = 10 $$ The maximum arity we support. diff --git a/googlemock/include/gmock/gmock-generated-matchers.h.pump b/googlemock/include/gmock/gmock-generated-matchers.h.pump index 25d2da99..4fe0a61c 100644 --- a/googlemock/include/gmock/gmock-generated-matchers.h.pump +++ b/googlemock/include/gmock/gmock-generated-matchers.h.pump @@ -1,6 +1,6 @@ $$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert it to -$$ gmock-generated-actions.h. +$$ This is a Pump source file. Please use Pump to convert +$$ it to gmock-generated-matchers.h. $$ $var n = 10 $$ The maximum arity we support. $$ }} This line fixes auto-indentation of the following code in Emacs. diff --git a/googlemock/include/gmock/gmock-generated-nice-strict.h.pump b/googlemock/include/gmock/gmock-generated-nice-strict.h.pump index 4973c356..378c40f1 100644 --- a/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +++ b/googlemock/include/gmock/gmock-generated-nice-strict.h.pump @@ -1,6 +1,6 @@ $$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert it to -$$ gmock-generated-nice-strict.h. +$$ This is a Pump source file. Please use Pump to convert +$$ it to gmock-generated-nice-strict.h. $$ $var n = 10 $$ The maximum arity we support. // Copyright 2008, Google Inc. diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 39a3fe74..2ae94df2 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -56,7 +56,6 @@ # pragma warning(disable:4800) #endif - namespace testing { namespace internal { From 03be5df17cc7e377a2cad4e110f2f6270d212eb9 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 09:59:09 -0400 Subject: [PATCH 16/32] cont. --- googlemock/src/gmock-spec-builders.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 2ae94df2..71892126 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -51,7 +51,7 @@ // Silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 14 -#ifdef _MSC_VER && _MSC_VER == 1900 +#ifdef (_MSC_VER && _MSC_VER == 1900) # pragma warning(push) # pragma warning(disable:4800) #endif @@ -874,6 +874,6 @@ InSequence::~InSequence() { } // namespace testing -#ifdef _MSC_VER && _MSC_VER == 1900 +#ifdef (_MSC_VER && _MSC_VER == 1900) # pragma warning(pop) #endif From 61e8a0b10b800ab527ecd19f913b2f6c850db541 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 10:08:12 -0400 Subject: [PATCH 17/32] syntax --- googlemock/src/gmock-spec-builders.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 71892126..8f8a2d7e 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -51,7 +51,7 @@ // Silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 14 -#ifdef (_MSC_VER && _MSC_VER == 1900) +#ifdef _MSC_VER && (_MSC_VER == 1900) # pragma warning(push) # pragma warning(disable:4800) #endif @@ -874,6 +874,6 @@ InSequence::~InSequence() { } // namespace testing -#ifdef (_MSC_VER && _MSC_VER == 1900) +#ifdef _MSC_VER && (_MSC_VER == 1900) # pragma warning(pop) #endif From 35a709a701cbebfcc685e35d0732dca10bac7763 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 10:25:59 -0400 Subject: [PATCH 18/32] preproc syntax ( I can never remember it) --- googlemock/src/gmock-spec-builders.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 8f8a2d7e..c8241c3d 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -51,9 +51,11 @@ // Silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 14 -#ifdef _MSC_VER && (_MSC_VER == 1900) -# pragma warning(push) -# pragma warning(disable:4800) +#ifdef _MSC_VER +#if _MSC_VER == 1900 +# pragma warning(push) +# pragma warning(disable:4800) +#endif #endif namespace testing { @@ -874,6 +876,8 @@ InSequence::~InSequence() { } // namespace testing -#ifdef _MSC_VER && (_MSC_VER == 1900) -# pragma warning(pop) +#ifdef _MSC_VER +#if _MSC_VER == 1900 +# pragma warning(pop) +#endif #endif From 6525044ce20c22974d9eeaa1726b826c521fa84e Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 10:51:15 -0400 Subject: [PATCH 19/32] And also silence for MSVS14 --- googlemock/src/gmock-spec-builders.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index c8241c3d..619c0c5b 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -50,9 +50,9 @@ #endif // Silence C4800 (C4800: 'int *const ': forcing value -// to bool 'true' or 'false') for MSVC 14 +// to bool 'true' or 'false') for MSVC 14,15 #ifdef _MSC_VER -#if _MSC_VER == 1900 +#if _MSC_VER <= 1900 # pragma warning(push) # pragma warning(disable:4800) #endif From c4e3d77ddc155a32e9f98f64ea1e111a5cce0e43 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 11:22:11 -0400 Subject: [PATCH 20/32] More msvc 14 --- googlemock/test/gmock-actions_test.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index ea6129d7..f8b9a1ef 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -43,6 +43,16 @@ #include "gtest/gtest.h" #include "gtest/gtest-spi.h" +// Silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 14,15 +#ifdef _MSC_VER +#if _MSC_VER <= 1900 +# pragma warning(push) +# pragma warning(disable:4800) +#endif +#endif + + namespace { // This list should be kept sorted. @@ -1556,3 +1566,9 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) { #endif // GTEST_LANG_CXX11 } // Unnamed namespace + +#ifdef _MSC_VER +#if _MSC_VER == 1900 +# pragma warning(pop) +#endif +#endif From 8bc7c631e848e7fc9eef2d95eeac12966caefb43 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 11:35:01 -0400 Subject: [PATCH 21/32] testing msvc again --- googlemock/test/gmock-actions_test.cc | 16 ---------------- googlemock/test/gmock-more-actions_test.cc | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index f8b9a1ef..ea6129d7 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -43,16 +43,6 @@ #include "gtest/gtest.h" #include "gtest/gtest-spi.h" -// Silence C4800 (C4800: 'int *const ': forcing value -// to bool 'true' or 'false') for MSVC 14,15 -#ifdef _MSC_VER -#if _MSC_VER <= 1900 -# pragma warning(push) -# pragma warning(disable:4800) -#endif -#endif - - namespace { // This list should be kept sorted. @@ -1566,9 +1556,3 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) { #endif // GTEST_LANG_CXX11 } // Unnamed namespace - -#ifdef _MSC_VER -#if _MSC_VER == 1900 -# pragma warning(pop) -#endif -#endif diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc index f5e28eae..e9b272b3 100644 --- a/googlemock/test/gmock-more-actions_test.cc +++ b/googlemock/test/gmock-more-actions_test.cc @@ -42,6 +42,15 @@ #include "gtest/gtest.h" #include "gtest/internal/gtest-linked_ptr.h" +// Silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 14,15 +#ifdef _MSC_VER +#if _MSC_VER <= 1900 +# pragma warning(push) +# pragma warning(disable:4800) +#endif +#endif + namespace testing { namespace gmock_more_actions_test { @@ -709,3 +718,8 @@ TEST(ReturnPointeeTest, Works) { } // namespace gmock_generated_actions_test } // namespace testing +#ifdef _MSC_VER +#if _MSC_VER == 1900 +# pragma warning(pop) +#endif +#endif From 431bfdcaf4a0f08c7ebd571291bf41d06195c20d Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 11:48:02 -0400 Subject: [PATCH 22/32] msvc 14 --- googlemock/src/gmock-all.cc | 16 ++++++++++++++++ googlemock/test/gmock-more-actions_test.cc | 14 -------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/googlemock/src/gmock-all.cc b/googlemock/src/gmock-all.cc index 7aebce7a..203bdb93 100644 --- a/googlemock/src/gmock-all.cc +++ b/googlemock/src/gmock-all.cc @@ -37,6 +37,16 @@ // This line ensures that gmock.h can be compiled on its own, even // when it's fused. + +// Silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 14,15 +#ifdef _MSC_VER +#if _MSC_VER <= 1900 +# pragma warning(push) +# pragma warning(disable:4800) +#endif +#endif + #include "gmock/gmock.h" // The following lines pull in the real gmock *.cc files. @@ -45,3 +55,9 @@ #include "src/gmock-matchers.cc" #include "src/gmock-spec-builders.cc" #include "src/gmock.cc" + +#ifdef _MSC_VER +#if _MSC_VER == 1900 +# pragma warning(pop) +#endif +#endif diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc index e9b272b3..f5e28eae 100644 --- a/googlemock/test/gmock-more-actions_test.cc +++ b/googlemock/test/gmock-more-actions_test.cc @@ -42,15 +42,6 @@ #include "gtest/gtest.h" #include "gtest/internal/gtest-linked_ptr.h" -// Silence C4800 (C4800: 'int *const ': forcing value -// to bool 'true' or 'false') for MSVC 14,15 -#ifdef _MSC_VER -#if _MSC_VER <= 1900 -# pragma warning(push) -# pragma warning(disable:4800) -#endif -#endif - namespace testing { namespace gmock_more_actions_test { @@ -718,8 +709,3 @@ TEST(ReturnPointeeTest, Works) { } // namespace gmock_generated_actions_test } // namespace testing -#ifdef _MSC_VER -#if _MSC_VER == 1900 -# pragma warning(pop) -#endif -#endif From c4684b49cf0d4334dfb522fcb3c8012cb63a4f61 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 12:03:40 -0400 Subject: [PATCH 23/32] more msvc --- googlemock/src/gmock-all.cc | 16 ---------------- googlemock/test/gmock_all_test.cc | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/googlemock/src/gmock-all.cc b/googlemock/src/gmock-all.cc index 203bdb93..7aebce7a 100644 --- a/googlemock/src/gmock-all.cc +++ b/googlemock/src/gmock-all.cc @@ -37,16 +37,6 @@ // This line ensures that gmock.h can be compiled on its own, even // when it's fused. - -// Silence C4800 (C4800: 'int *const ': forcing value -// to bool 'true' or 'false') for MSVC 14,15 -#ifdef _MSC_VER -#if _MSC_VER <= 1900 -# pragma warning(push) -# pragma warning(disable:4800) -#endif -#endif - #include "gmock/gmock.h" // The following lines pull in the real gmock *.cc files. @@ -55,9 +45,3 @@ #include "src/gmock-matchers.cc" #include "src/gmock-spec-builders.cc" #include "src/gmock.cc" - -#ifdef _MSC_VER -#if _MSC_VER == 1900 -# pragma warning(pop) -#endif -#endif diff --git a/googlemock/test/gmock_all_test.cc b/googlemock/test/gmock_all_test.cc index 56d6c49c..bb87729e 100644 --- a/googlemock/test/gmock_all_test.cc +++ b/googlemock/test/gmock_all_test.cc @@ -36,6 +36,15 @@ // includes most such tests, making it easier for these users to maintain // their build scripts (they just need to build this file, even though the // below list of actual *_test.cc files might change). +// Silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 14,15 +#ifdef _MSC_VER +#if _MSC_VER <= 1900 +# pragma warning(push) +# pragma warning(disable:4800) +#endif +#endif + #include "test/gmock-actions_test.cc" #include "test/gmock-cardinalities_test.cc" #include "test/gmock-generated-actions_test.cc" @@ -49,3 +58,9 @@ #include "test/gmock-port_test.cc" #include "test/gmock-spec-builders_test.cc" #include "test/gmock_test.cc" + +#ifdef _MSC_VER +#if _MSC_VER == 1900 +# pragma warning(pop) +#endif +#endif From e93a0ece26844351da7cdc675a55a2520412134d Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 13:51:01 -0400 Subject: [PATCH 24/32] msvc --- googlemock/test/gmock-actions_test.cc | 13 +++++++++++++ googlemock/test/gmock_all_test.cc | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index ea6129d7..cd517a7d 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -33,6 +33,13 @@ // // This file tests the built-in actions. +#ifdef _MSC_VER +#if _MSC_VER <= 1900 +# pragma warning(push) +# pragma warning(disable:4800) +#endif +#endif + #include "gmock/gmock-actions.h" #include #include @@ -1556,3 +1563,9 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) { #endif // GTEST_LANG_CXX11 } // Unnamed namespace + +#ifdef _MSC_VER +#if _MSC_VER == 1900 +# pragma warning(pop) +#endif +#endif diff --git a/googlemock/test/gmock_all_test.cc b/googlemock/test/gmock_all_test.cc index bb87729e..fa9d84b6 100644 --- a/googlemock/test/gmock_all_test.cc +++ b/googlemock/test/gmock_all_test.cc @@ -38,13 +38,6 @@ // below list of actual *_test.cc files might change). // Silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 14,15 -#ifdef _MSC_VER -#if _MSC_VER <= 1900 -# pragma warning(push) -# pragma warning(disable:4800) -#endif -#endif - #include "test/gmock-actions_test.cc" #include "test/gmock-cardinalities_test.cc" #include "test/gmock-generated-actions_test.cc" @@ -59,8 +52,3 @@ #include "test/gmock-spec-builders_test.cc" #include "test/gmock_test.cc" -#ifdef _MSC_VER -#if _MSC_VER == 1900 -# pragma warning(pop) -#endif -#endif From 44da2b9ac5dff919966d7bf488c7058bc8563023 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 15:23:00 -0400 Subject: [PATCH 25/32] cont --- googlemock/test/gmock_all_test.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/googlemock/test/gmock_all_test.cc b/googlemock/test/gmock_all_test.cc index fa9d84b6..56d6c49c 100644 --- a/googlemock/test/gmock_all_test.cc +++ b/googlemock/test/gmock_all_test.cc @@ -36,8 +36,6 @@ // includes most such tests, making it easier for these users to maintain // their build scripts (they just need to build this file, even though the // below list of actual *_test.cc files might change). -// Silence C4800 (C4800: 'int *const ': forcing value -// to bool 'true' or 'false') for MSVC 14,15 #include "test/gmock-actions_test.cc" #include "test/gmock-cardinalities_test.cc" #include "test/gmock-generated-actions_test.cc" @@ -51,4 +49,3 @@ #include "test/gmock-port_test.cc" #include "test/gmock-spec-builders_test.cc" #include "test/gmock_test.cc" - From 57d6e824b44be45a084fe6baffdfc27b8f8d623f Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 15:33:56 -0400 Subject: [PATCH 26/32] more --- googletest/include/gtest/gtest.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index cbab121a..16183e11 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -82,14 +82,15 @@ namespace testing { -// Silence C4100 (unreferenced formal parameter) for MSVC +// Silence C4100 (unreferenced formal parameter) for MSVC 14 and 15 #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -# pragma warning(disable:4805) +# if _MSC_VER <= 1900 +# pragma warning(push) +# pragma warning(disable:4100) +# pragma warning(disable:4805) +# endif #endif - // Declares the flags. // This flag temporary enables the disabled tests. @@ -2307,7 +2308,9 @@ bool StaticAssertTypeEq() { GTEST_API_ std::string TempDir(); #ifdef _MSC_VER -# pragma warning(pop) +# if _MSC_VER <= 1900 +# pragma warning(pop) +# endif #endif } // namespace testing From 055f32199a81a159eebeaabb6666d6de11127064 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 15:38:38 -0400 Subject: [PATCH 27/32] tuning --- googlemock/test/gmock_output_test_.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index d5f909d9..4166c6c6 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -42,8 +42,10 @@ // Silence C4100 (unreferenced formal parameter) for MSVC #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) +# if _MSC_VER <= 1900 +# pragma warning(push) +# pragma warning(disable:4100) +# endif #endif @@ -308,5 +310,7 @@ int main(int argc, char **argv) { } #ifdef _MSC_VER -# pragma warning(pop) +# if _MSC_VER <= 1900 +# pragma warning(pop) +# endif #endif From 2de24fbf7a26e679e8dc7d185addd3dc820f347c Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 15:39:12 -0400 Subject: [PATCH 28/32] tuning --- googlemock/test/gmock_output_test_.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index 4166c6c6..56a00b21 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -40,7 +40,7 @@ #include "gtest/gtest.h" -// Silence C4100 (unreferenced formal parameter) for MSVC +// Silence C4100 (unreferenced formal parameter) for MSVC 14 and 15 #ifdef _MSC_VER # if _MSC_VER <= 1900 # pragma warning(push) From 05b5a53898c2466e49f37e84324644949d279b34 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 15:50:19 -0400 Subject: [PATCH 29/32] formatting --- googlemock/src/gmock-spec-builders.cc | 2 +- googlemock/test/gmock-actions_test.cc | 3 +++ googlemock/test/gmock_output_test_.cc | 2 -- googletest/include/gtest/gtest.h | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 619c0c5b..22d002fe 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -877,7 +877,7 @@ InSequence::~InSequence() { } // namespace testing #ifdef _MSC_VER -#if _MSC_VER == 1900 +#if _MSC_VER <= 1900 # pragma warning(pop) #endif #endif diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index cd517a7d..5dd48460 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -33,6 +33,8 @@ // // This file tests the built-in actions. +// Silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 14,15 #ifdef _MSC_VER #if _MSC_VER <= 1900 # pragma warning(push) @@ -1569,3 +1571,4 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) { # pragma warning(pop) #endif #endif + diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index 56a00b21..a01b95e5 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -39,7 +39,6 @@ #include "gtest/gtest.h" - // Silence C4100 (unreferenced formal parameter) for MSVC 14 and 15 #ifdef _MSC_VER # if _MSC_VER <= 1900 @@ -48,7 +47,6 @@ # endif #endif - using testing::_; using testing::AnyNumber; using testing::Ge; diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 16183e11..c5d1b7c8 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -82,7 +82,8 @@ namespace testing { -// Silence C4100 (unreferenced formal parameter) for MSVC 14 and 15 +// Silence C4100 (unreferenced formal parameter) and 4805 +// unsafe mix of bool and type int for MSVC 14 and 15 #ifdef _MSC_VER # if _MSC_VER <= 1900 # pragma warning(push) @@ -91,6 +92,7 @@ namespace testing { # endif #endif + // Declares the flags. // This flag temporary enables the disabled tests. From f5871009e6d8db73c0516efeb2955436b7134fb4 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 16:04:48 -0400 Subject: [PATCH 30/32] yet more --- .../gmock/internal/custom/gmock-generated-actions.h.pump | 2 +- googletest/include/gtest/gtest.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump b/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump index d26c8a08..03cfd8c5 100644 --- a/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +++ b/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump @@ -1,5 +1,5 @@ $$ -*- mode: c++; -*- -$$ This is a Pump source file (http://go/pump). Please use Pump to convert +$$ This is a Pump source file. Please use Pump to convert $$ it to callback-actions.h. $$ $var max_callback_arity = 5 diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index c5d1b7c8..efa98d51 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -83,12 +83,12 @@ namespace testing { // Silence C4100 (unreferenced formal parameter) and 4805 -// unsafe mix of bool and type int for MSVC 14 and 15 +// unsafe mix of type 'const int' and type 'const bool' #ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4805) # if _MSC_VER <= 1900 -# pragma warning(push) # pragma warning(disable:4100) -# pragma warning(disable:4805) # endif #endif From c1d4c34233e05bbcd4ba4abd72198327f550818f Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 16:13:45 -0400 Subject: [PATCH 31/32] this should be it --- googletest/include/gtest/gtest.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index efa98d51..1c39310b 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -87,9 +87,7 @@ namespace testing { #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable:4805) -# if _MSC_VER <= 1900 # pragma warning(disable:4100) -# endif #endif @@ -2310,9 +2308,7 @@ bool StaticAssertTypeEq() { GTEST_API_ std::string TempDir(); #ifdef _MSC_VER -# if _MSC_VER <= 1900 # pragma warning(pop) -# endif #endif } // namespace testing From 64d24b810f37681680a84d615f2601ac73dea78a Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Mon, 9 Apr 2018 16:24:30 -0400 Subject: [PATCH 32/32] ... and this --- googlemock/test/gmock_output_test_.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index a01b95e5..1b59eb3f 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -39,12 +39,10 @@ #include "gtest/gtest.h" -// Silence C4100 (unreferenced formal parameter) for MSVC 14 and 15 +// Silence C4100 (unreferenced formal parameter) #ifdef _MSC_VER -# if _MSC_VER <= 1900 -# pragma warning(push) -# pragma warning(disable:4100) -# endif +# pragma warning(push) +# pragma warning(disable:4100) #endif using testing::_; @@ -308,7 +306,5 @@ int main(int argc, char **argv) { } #ifdef _MSC_VER -# if _MSC_VER <= 1900 -# pragma warning(pop) -# endif +# pragma warning(pop) #endif