From 6e1970e2376c14bf658eb88f655a054030353f9f Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 10 Aug 2017 09:41:09 -0400 Subject: Adding a flag option to change the default mock type --- googlemock/include/gmock/gmock-spec-builders.h | 1 - googlemock/include/gmock/gmock.h | 1 + googlemock/src/gmock-spec-builders.cc | 3 +- googlemock/src/gmock.cc | 24 ++++++++++++++- googlemock/test/gmock-spec-builders_test.cc | 35 ++++++++++++++++++++++ googlemock/test/gmock_test.cc | 41 ++++++++++++++++++++++++++ 6 files changed, 102 insertions(+), 3 deletions(-) (limited to 'googlemock') diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 39f72129..96802444 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -363,7 +363,6 @@ enum CallReaction { kAllow, kWarn, kFail, - kDefault = kWarn // By default, warn about uninteresting calls. }; } // namespace internal diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h index 6735c71b..5764bc85 100644 --- a/googlemock/include/gmock/gmock.h +++ b/googlemock/include/gmock/gmock.h @@ -71,6 +71,7 @@ namespace testing { // Declares Google Mock flags that we want a user to use programmatically. GMOCK_DECLARE_bool_(catch_leaked_mocks); GMOCK_DECLARE_string_(verbose); +GMOCK_DECLARE_int32_(default_mock_behavior); // Initializes Google Mock. This must be called before running the // tests. In particular, it parses the command line for the flags diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 2fa1ee4b..1fc8d988 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -648,7 +648,8 @@ internal::CallReaction Mock::GetReactionOnUninterestingCalls( GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); return (g_uninteresting_call_reaction.count(mock_obj) == 0) ? - internal::kDefault : g_uninteresting_call_reaction[mock_obj]; + static_cast(GMOCK_FLAG(default_mock_behavior)) : + g_uninteresting_call_reaction[mock_obj]; } // Tells Google Mock to ignore mock_obj when checking for leaked mock diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc index eac3d842..3c370510 100644 --- a/googlemock/src/gmock.cc +++ b/googlemock/src/gmock.cc @@ -48,6 +48,13 @@ GMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity, " warning - prints warnings and errors.\n" " error - prints errors only."); +GMOCK_DEFINE_int32_(default_mock_behavior, 1, + "Controls the default behavior of mocks." + " Valid values:\n" + " 0 - by default, mocks act as NiceMocks.\n" + " 1 - by default, mocks act as NaggyMocks.\n" + " 2 - by default, mocks act as StrictMocks."); + namespace internal { // Parses a string as a command line flag. The string should have the @@ -120,6 +127,19 @@ static bool ParseGoogleMockStringFlag(const char* str, const char* flag, return true; } +static bool ParseGoogleMockIntFlag(const char* str, const char* flag, + int* value) { + // Gets the value of the flag as a string. + const char* const value_str = ParseGoogleMockFlagValue(str, flag, true); + + // Aborts if the parsing failed. + if (value_str == NULL) return false; + + // Sets *value to the value of the flag. + *value = atoi(value_str); + return true; +} + // The internal implementation of InitGoogleMock(). // // The type parameter CharType can be instantiated to either char or @@ -138,7 +158,9 @@ void InitGoogleMockImpl(int* argc, CharType** argv) { // Do we see a Google Mock flag? if (ParseGoogleMockBoolFlag(arg, "catch_leaked_mocks", &GMOCK_FLAG(catch_leaked_mocks)) || - ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose))) { + ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose)) || + ParseGoogleMockIntFlag(arg, "default_mock_behavior", + &GMOCK_FLAG(default_mock_behavior))) { // Yes. Shift the remainder of the argv list left by one. Note // that argv has (*argc + 1) elements, the last one always being // NULL. The following loop moves the trailing NULL element as diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 389e0709..00cb1198 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -93,8 +93,11 @@ using testing::Sequence; using testing::SetArgPointee; using testing::internal::ExpectationTester; using testing::internal::FormatFileLocation; +using testing::internal::kAllow; using testing::internal::kErrorVerbosity; +using testing::internal::kFail; using testing::internal::kInfoVerbosity; +using testing::internal::kWarn; using testing::internal::kWarningVerbosity; using testing::internal::linked_ptr; @@ -691,6 +694,38 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) { b.DoB(); } +TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { + int original_behavior = testing::GMOCK_FLAG(default_mock_behavior); + + testing::GMOCK_FLAG(default_mock_behavior) = kAllow; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + std::string output = GetCapturedStdout(); + EXPECT_TRUE(output.empty()) << output; + + testing::GMOCK_FLAG(default_mock_behavior) = kWarn; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + std::string warning_output = GetCapturedStdout(); + EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + + testing::GMOCK_FLAG(default_mock_behavior) = kFail; + EXPECT_NONFATAL_FAILURE({ + MockA a; + a.DoA(0); + },"Uninteresting mock function call"); + + testing::GMOCK_FLAG(default_mock_behavior) = original_behavior; +} + + #endif // GTEST_HAS_STREAM_REDIRECTION // Tests the semantics of ON_CALL(). diff --git a/googlemock/test/gmock_test.cc b/googlemock/test/gmock_test.cc index d8d0c57b..28995345 100644 --- a/googlemock/test/gmock_test.cc +++ b/googlemock/test/gmock_test.cc @@ -40,6 +40,7 @@ #if !defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) +using testing::GMOCK_FLAG(default_mock_behavior); using testing::GMOCK_FLAG(verbose); using testing::InitGoogleMock; @@ -103,6 +104,26 @@ TEST(InitGoogleMockTest, ParsesSingleFlag) { TestInitGoogleMock(argv, new_argv, "info"); } +TEST(InitGoogleMockTest, ParsesMultipleFlags) { + int old_default_behavior = GMOCK_FLAG(default_mock_behavior); + const wchar_t* argv[] = { + L"foo.exe", + L"--gmock_verbose=info", + L"--gmock_default_mock_behavior=2", + NULL + }; + + const wchar_t* new_argv[] = { + L"foo.exe", + NULL + }; + + TestInitGoogleMock(argv, new_argv, "info"); + EXPECT_EQ(2, GMOCK_FLAG(default_mock_behavior)); + EXPECT_NE(2, old_default_behavior); + GMOCK_FLAG(default_mock_behavior) = old_default_behavior; +} + TEST(InitGoogleMockTest, ParsesUnrecognizedFlag) { const char* argv[] = { "foo.exe", @@ -177,6 +198,26 @@ TEST(WideInitGoogleMockTest, ParsesSingleFlag) { TestInitGoogleMock(argv, new_argv, "info"); } +TEST(WideInitGoogleMockTest, ParsesMultipleFlags) { + int old_default_behavior = GMOCK_FLAG(default_mock_behavior); + const wchar_t* argv[] = { + L"foo.exe", + L"--gmock_verbose=info", + L"--gmock_default_mock_behavior=2", + NULL + }; + + const wchar_t* new_argv[] = { + L"foo.exe", + NULL + }; + + TestInitGoogleMock(argv, new_argv, "info"); + EXPECT_EQ(2, GMOCK_FLAG(default_mock_behavior)); + EXPECT_NE(2, old_default_behavior); + GMOCK_FLAG(default_mock_behavior) = old_default_behavior; +} + TEST(WideInitGoogleMockTest, ParsesUnrecognizedFlag) { const wchar_t* argv[] = { L"foo.exe", -- cgit v1.2.3 From 8604c4adac40573f806cfadae44e22f8dfaf212a Mon Sep 17 00:00:00 2001 From: David Seifert Date: Mon, 14 Aug 2017 13:45:56 +0200 Subject: Add support for pkgconfig --- googlemock/CMakeLists.txt | 19 ++++++++++++++++++- googlemock/cmake/gmock.pc.in | 9 +++++++++ googlemock/cmake/gmock_main.pc.in | 9 +++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 googlemock/cmake/gmock.pc.in create mode 100644 googlemock/cmake/gmock_main.pc.in (limited to 'googlemock') diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt index c3c8aaeb..bd759dfd 100644 --- a/googlemock/CMakeLists.txt +++ b/googlemock/CMakeLists.txt @@ -37,7 +37,12 @@ endif() # as ${gmock_SOURCE_DIR} and to the root binary directory as # ${gmock_BINARY_DIR}. # Language "C" is required for find_package(Threads). -project(gmock CXX C) +if (CMAKE_VERSION VERSION_LESS 3.0) + project(gmock CXX C) +else() + cmake_policy(SET CMP0048 NEW) + project(gmock VERSION 1.9.0 LANGUAGES CXX C) +endif() cmake_minimum_required(VERSION 2.6.4) if (COMMAND set_up_hermetic_build) @@ -110,6 +115,18 @@ if(INSTALL_GMOCK) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(DIRECTORY ${gmock_SOURCE_DIR}/include/gmock DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + # configure and install pkgconfig files + configure_file( + cmake/gmock.pc.in + "${CMAKE_BINARY_DIR}/gmock.pc" + @ONLY) + configure_file( + cmake/gmock_main.pc.in + "${CMAKE_BINARY_DIR}/gmock_main.pc" + @ONLY) + install(FILES "${CMAKE_BINARY_DIR}/gmock.pc" "${CMAKE_BINARY_DIR}/gmock_main.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() ######################################################################## diff --git a/googlemock/cmake/gmock.pc.in b/googlemock/cmake/gmock.pc.in new file mode 100644 index 00000000..c4416426 --- /dev/null +++ b/googlemock/cmake/gmock.pc.in @@ -0,0 +1,9 @@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: gmock +Description: GoogleMock (without main() function) +Version: @PROJECT_VERSION@ +URL: https://github.com/google/googletest +Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@ +Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ diff --git a/googlemock/cmake/gmock_main.pc.in b/googlemock/cmake/gmock_main.pc.in new file mode 100644 index 00000000..c377dba1 --- /dev/null +++ b/googlemock/cmake/gmock_main.pc.in @@ -0,0 +1,9 @@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: gmock_main +Description: GoogleMock (with main() function) +Version: @PROJECT_VERSION@ +URL: https://github.com/google/googletest +Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@ +Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ -- cgit v1.2.3 From 5b4166f05fbc133d165b54e25fef2c88430bbc2c Mon Sep 17 00:00:00 2001 From: Maurice Gilden Date: Thu, 27 Jul 2017 11:12:12 +0200 Subject: Add function name to exception if there's no default action --- googlemock/src/gmock-spec-builders.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 2fa1ee4b..f761f97e 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -364,7 +364,7 @@ UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args) if (!need_to_report_uninteresting_call) { // Perform the action without printing the call information. - return this->UntypedPerformDefaultAction(untyped_args, ""); + return this->UntypedPerformDefaultAction(untyped_args, "Function call: " + std::string(Name())); } // Warns about the uninteresting call. -- cgit v1.2.3 From a2803bc37dafdaad05b335e64a83aff03096a4ba Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Wed, 16 Aug 2017 12:43:26 -0400 Subject: Handling invalid flag values --- googlemock/src/gmock-spec-builders.cc | 9 ++++++++- googlemock/test/gmock-spec-builders_test.cc | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 1fc8d988..a725d185 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -508,6 +508,13 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() return expectations_met; } +CallReaction intToCallReaction(int mock_behavior) { + if (mock_behavior >= kAllow && mock_behavior <= kFail) { + return static_cast(mock_behavior); + } + return kWarn; +} + } // namespace internal // Class Mock. @@ -648,7 +655,7 @@ internal::CallReaction Mock::GetReactionOnUninterestingCalls( GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); return (g_uninteresting_call_reaction.count(mock_obj) == 0) ? - static_cast(GMOCK_FLAG(default_mock_behavior)) : + internal::intToCallReaction(GMOCK_FLAG(default_mock_behavior)) : g_uninteresting_call_reaction[mock_obj]; } diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 00cb1198..34088de1 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -722,6 +722,26 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { a.DoA(0); },"Uninteresting mock function call"); + // Out of bounds values are converted to kWarn + testing::GMOCK_FLAG(default_mock_behavior) = -1; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + warning_output = GetCapturedStdout(); + EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + testing::GMOCK_FLAG(default_mock_behavior) = 3; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + warning_output = GetCapturedStdout(); + EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + testing::GMOCK_FLAG(default_mock_behavior) = original_behavior; } -- cgit v1.2.3 From 95f18d99383c27bf645e8dc4f5dcaa188f6bafe3 Mon Sep 17 00:00:00 2001 From: Maurice Gilden Date: Fri, 18 Aug 2017 11:21:28 +0200 Subject: adds test for NiceMock with unknown return value --- googlemock/test/gmock-nice-strict_test.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'googlemock') diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index 5d6ccc4f..5e6d53be 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -79,6 +79,7 @@ class MockFoo : public Foo { MOCK_METHOD0(DoThis, void()); MOCK_METHOD1(DoThat, int(bool flag)); + MOCK_METHOD0(ReturnSomething, Mock()); private: GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); @@ -207,6 +208,20 @@ TEST(NiceMockTest, AllowsExpectedCall) { nice_foo.DoThis(); } +// Tests that an unexpected call on a nice mock which returns a non-built in +// default value throws an exception and the exception contains the name of +// the method. +TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { + NiceMock nice_foo; + try { + nice_foo.ReturnSomething(); + FAIL(); + } catch (const std::runtime_error& ex) { + const std::string exception_msg(ex.what()); + EXPECT_NE(exception_msg.find("ReturnSomething"), std::string::npos); + } +} + // Tests that an unexpected call on a nice mock fails. TEST(NiceMockTest, UnexpectedCallFails) { NiceMock nice_foo; -- cgit v1.2.3 From cc99900036ae3514d8918acba87817fa24f6c993 Mon Sep 17 00:00:00 2001 From: Maurice Gilden Date: Fri, 18 Aug 2017 11:46:15 +0200 Subject: Fix test if exceptions are not supported --- googlemock/test/gmock-nice-strict_test.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'googlemock') diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index 5e6d53be..86706814 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -213,6 +213,7 @@ TEST(NiceMockTest, AllowsExpectedCall) { // the method. TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { NiceMock nice_foo; +#if GTEST_HAS_EXCEPTIONS try { nice_foo.ReturnSomething(); FAIL(); @@ -220,6 +221,11 @@ TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { const std::string exception_msg(ex.what()); EXPECT_NE(exception_msg.find("ReturnSomething"), std::string::npos); } +#else + EXPECT_DEATH_IF_SUPPORTED({ + nice_foo.ReturnSomething(); + }, ""); +#endif } // Tests that an unexpected call on a nice mock fails. -- cgit v1.2.3 From 36777251c07788549eaa72a9be0cf482ab322c46 Mon Sep 17 00:00:00 2001 From: Maurice Gilden Date: Fri, 18 Aug 2017 12:28:50 +0200 Subject: Switch return type to class without default constructor --- googlemock/test/gmock-nice-strict_test.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index 86706814..1d7784b1 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -62,6 +62,12 @@ using testing::internal::CaptureStdout; using testing::internal::GetCapturedStdout; #endif +// Dummy class without default constructor. +class Dummy { + public: + Dummy(int) {} +}; + // Defines some mock classes needed by the tests. class Foo { @@ -79,7 +85,7 @@ class MockFoo : public Foo { MOCK_METHOD0(DoThis, void()); MOCK_METHOD1(DoThat, int(bool flag)); - MOCK_METHOD0(ReturnSomething, Mock()); + MOCK_METHOD0(ReturnSomething, Dummy()); private: GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); -- cgit v1.2.3 From b0ed43e72447c99f297dc86a75d7d58d53af5a07 Mon Sep 17 00:00:00 2001 From: Maurice Gilden Date: Fri, 18 Aug 2017 15:27:02 +0200 Subject: Change tabs to spaces in test case --- googlemock/test/gmock-nice-strict_test.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'googlemock') diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index 1d7784b1..a8032e24 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -218,19 +218,19 @@ TEST(NiceMockTest, AllowsExpectedCall) { // default value throws an exception and the exception contains the name of // the method. TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { - NiceMock nice_foo; + NiceMock nice_foo; #if GTEST_HAS_EXCEPTIONS - try { - nice_foo.ReturnSomething(); - FAIL(); - } catch (const std::runtime_error& ex) { - const std::string exception_msg(ex.what()); - EXPECT_NE(exception_msg.find("ReturnSomething"), std::string::npos); - } + try { + nice_foo.ReturnSomething(); + FAIL(); + } catch (const std::runtime_error& ex) { + const std::string exception_msg(ex.what()); + EXPECT_NE(exception_msg.find("ReturnSomething"), std::string::npos); + } #else - EXPECT_DEATH_IF_SUPPORTED({ - nice_foo.ReturnSomething(); - }, ""); + EXPECT_DEATH_IF_SUPPORTED({ + nice_foo.ReturnSomething(); + }, ""); #endif } -- cgit v1.2.3 From 026735daf34cf180e34a976b3167cc4b311e3f11 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Sun, 20 Aug 2017 15:15:31 -0400 Subject: Proposing these changes, please review Slightly better names and cleaner tests. Please review --- googlemock/test/gmock-nice-strict_test.cc | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'googlemock') diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index a8032e24..2cb0a96d 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -62,10 +62,10 @@ using testing::internal::CaptureStdout; using testing::internal::GetCapturedStdout; #endif -// Dummy class without default constructor. -class Dummy { +// Class without default constructor. +class NotDefaultConstructible { public: - Dummy(int) {} + NotDefaultConstructible(int) {} }; // Defines some mock classes needed by the tests. @@ -85,7 +85,7 @@ class MockFoo : public Foo { MOCK_METHOD0(DoThis, void()); MOCK_METHOD1(DoThat, int(bool flag)); - MOCK_METHOD0(ReturnSomething, Dummy()); + MOCK_METHOD0(ReturnNonDefaultConstructible, NotDefaultConstructible()); private: GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); @@ -214,23 +214,20 @@ TEST(NiceMockTest, AllowsExpectedCall) { nice_foo.DoThis(); } -// Tests that an unexpected call on a nice mock which returns a non-built in -// default value throws an exception and the exception contains the name of -// the method. +// Tests that an unexpected call on a nice mock which returns a not-default-constructible +// type throws an exception and the exception contains the method's name. TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { NiceMock nice_foo; #if GTEST_HAS_EXCEPTIONS try { - nice_foo.ReturnSomething(); + nice_foo.ReturnNonDefaultConstructible(); FAIL(); } catch (const std::runtime_error& ex) { const std::string exception_msg(ex.what()); - EXPECT_NE(exception_msg.find("ReturnSomething"), std::string::npos); + EXPECT_THAT(ex.what(), HasSubstr("ReturnNonDefaultConstructible")); } #else - EXPECT_DEATH_IF_SUPPORTED({ - nice_foo.ReturnSomething(); - }, ""); + EXPECT_DEATH_IF_SUPPORTED({ nice_foo.ReturnNonDefaultConstructible(); }, ""); #endif } -- cgit v1.2.3 From 3cf65b5d86d46cceb96ac44672fad84e2d5ad5a7 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Sun, 20 Aug 2017 15:20:13 -0400 Subject: Added "explicit" as per compiler suggestion --- googlemock/test/gmock-nice-strict_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index 2cb0a96d..fce9ca5b 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -65,7 +65,7 @@ using testing::internal::GetCapturedStdout; // Class without default constructor. class NotDefaultConstructible { public: - NotDefaultConstructible(int) {} + explicit NotDefaultConstructible(int) {} }; // Defines some mock classes needed by the tests. -- cgit v1.2.3 From 1ee8079651584b6bcc444f4b7a66dd2c65a79eb6 Mon Sep 17 00:00:00 2001 From: Maurice Gilden Date: Mon, 21 Aug 2017 10:10:14 +0200 Subject: Remove unused variable --- googlemock/test/gmock-nice-strict_test.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc index fce9ca5b..0eac6439 100644 --- a/googlemock/test/gmock-nice-strict_test.cc +++ b/googlemock/test/gmock-nice-strict_test.cc @@ -223,7 +223,6 @@ TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) { nice_foo.ReturnNonDefaultConstructible(); FAIL(); } catch (const std::runtime_error& ex) { - const std::string exception_msg(ex.what()); EXPECT_THAT(ex.what(), HasSubstr("ReturnNonDefaultConstructible")); } #else -- cgit v1.2.3 From 966b549c88032ec43ecd344ab19ca9ca36c30ad9 Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Tue, 22 Aug 2017 16:06:26 +0200 Subject: Support ref-qualified member functions in Property(). --- googlemock/include/gmock/gmock-matchers.h | 35 ++++++++++++++++++++++++------- googlemock/test/gmock-matchers_test.cc | 20 ++++++++++++++++++ 2 files changed, 47 insertions(+), 8 deletions(-) (limited to 'googlemock') diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 3a97c438..c446bf7d 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -2232,7 +2232,10 @@ class FieldMatcher { // Implements the Property() matcher for matching a property // (i.e. return value of a getter method) of an object. -template +// +// Property is a const-qualified member function of Class returning +// PropertyType. +template class PropertyMatcher { public: // The property may have a reference type, so 'const PropertyType&' @@ -2241,8 +2244,7 @@ class PropertyMatcher { // PropertyType being a reference or not. typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty; - PropertyMatcher(PropertyType (Class::*property)() const, - const Matcher& matcher) + PropertyMatcher(Property property, const Matcher& matcher) : property_(property), matcher_(matcher) {} void DescribeTo(::std::ostream* os) const { @@ -2295,7 +2297,7 @@ class PropertyMatcher { return MatchAndExplainImpl(false_type(), *p, listener); } - PropertyType (Class::*property_)() const; + Property property_; const Matcher matcher_; GTEST_DISALLOW_ASSIGN_(PropertyMatcher); @@ -3908,11 +3910,13 @@ inline PolymorphicMatcher< // Property(&Foo::str, StartsWith("hi")) // matches a Foo object x iff x.str() starts with "hi". template -inline PolymorphicMatcher< - internal::PropertyMatcher > Property( - PropertyType (Class::*property)() const, const PropertyMatcher& matcher) { +inline PolymorphicMatcher > +Property(PropertyType (Class::*property)() const, + const PropertyMatcher& matcher) { return MakePolymorphicMatcher( - internal::PropertyMatcher( + internal::PropertyMatcher( property, MatcherCast(matcher))); // The call to MatcherCast() is required for supporting inner @@ -3921,6 +3925,21 @@ inline PolymorphicMatcher< // to compile where bar() returns an int32 and m is a matcher for int64. } +#if GTEST_LANG_CXX11 +// The same as above but for reference-qualified member functions. +template +inline PolymorphicMatcher > +Property(PropertyType (Class::*property)() const &, + const PropertyMatcher& matcher) { + return MakePolymorphicMatcher( + internal::PropertyMatcher( + property, + MatcherCast(matcher))); +} +#endif + // Creates a matcher that matches an object iff the result of applying // a callable to x matches 'matcher'. // For example, diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index f5ab7c81..fc867487 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -3588,10 +3588,15 @@ class AClass { // A getter that returns a reference to const. const std::string& s() const { return s_; } +#if GTEST_LANG_CXX11 + const std::string& s_ref() const & { return s_; } +#endif + void set_s(const std::string& new_s) { s_ = new_s; } // A getter that returns a reference to non-const. double& x() const { return x_; } + private: int n_; std::string s_; @@ -3635,6 +3640,21 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) { EXPECT_FALSE(m.Matches(a)); } +#if GTEST_LANG_CXX11 +// Tests that Property(&Foo::property, ...) works when property() is +// ref-qualified. +TEST(PropertyTest, WorksForRefQualifiedProperty) { + Matcher m = Property(&AClass::s_ref, StartsWith("hi")); + + AClass a; + a.set_s("hill"); + EXPECT_TRUE(m.Matches(a)); + + a.set_s("hole"); + EXPECT_FALSE(m.Matches(a)); +} +#endif + // Tests that Property(&Foo::property, ...) works when property() // returns a reference to non-const. TEST(PropertyTest, WorksForReferenceToNonConstProperty) { -- cgit v1.2.3 From 88269cd365fa5da9d2d6bd04a283ded660c1a0c3 Mon Sep 17 00:00:00 2001 From: Arkady Shapkin Date: Tue, 23 Feb 2016 23:17:36 +0300 Subject: Support x64 configuration for old VS2010 projects VS2010 solution only to simplify old users (who used these solutions) upgrading to new gtest/gmock, new users should use CMake generated solutions. VS2010 solution can be opened in any new VS. --- googlemock/msvc/2010/gmock.sln | 14 +++++ googlemock/msvc/2010/gmock.vcxproj | 75 ++++++++++++++++++++++++--- googlemock/msvc/2010/gmock_config.props | 4 +- googlemock/msvc/2010/gmock_main.vcxproj | 75 ++++++++++++++++++++++++--- googlemock/msvc/2010/gmock_test.vcxproj | 91 ++++++++++++++++++++++++++++++--- 5 files changed, 237 insertions(+), 22 deletions(-) (limited to 'googlemock') diff --git a/googlemock/msvc/2010/gmock.sln b/googlemock/msvc/2010/gmock.sln index d9496569..bb48f5be 100644 --- a/googlemock/msvc/2010/gmock.sln +++ b/googlemock/msvc/2010/gmock.sln @@ -10,21 +10,35 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.ActiveCfg = Debug|Win32 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.Build.0 = Debug|Win32 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|x64.ActiveCfg = Debug|x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|x64.Build.0 = Debug|x64 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.ActiveCfg = Release|Win32 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.Build.0 = Release|Win32 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|x64.ActiveCfg = Release|x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|x64.Build.0 = Release|x64 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.ActiveCfg = Debug|Win32 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.Build.0 = Debug|Win32 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|x64.ActiveCfg = Debug|x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|x64.Build.0 = Debug|x64 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.ActiveCfg = Release|Win32 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.Build.0 = Release|Win32 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|x64.ActiveCfg = Release|x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|x64.Build.0 = Release|x64 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.ActiveCfg = Debug|Win32 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.Build.0 = Debug|Win32 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|x64.ActiveCfg = Debug|x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|x64.Build.0 = Debug|x64 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.ActiveCfg = Release|Win32 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.Build.0 = Release|Win32 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|x64.ActiveCfg = Release|x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/googlemock/msvc/2010/gmock.vcxproj b/googlemock/msvc/2010/gmock.vcxproj index 21a85ef6..7bc71d31 100644 --- a/googlemock/msvc/2010/gmock.vcxproj +++ b/googlemock/msvc/2010/gmock.vcxproj @@ -1,14 +1,22 @@ - + Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5} @@ -20,10 +28,23 @@ StaticLibrary Unicode true + v100 + + + StaticLibrary + Unicode + true + v100 StaticLibrary Unicode + v100 + + + StaticLibrary + Unicode + v100 @@ -32,23 +53,39 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + Disabled ..\..\include;..\..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_VARIADIC_MAX=10;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -58,10 +95,34 @@ ProgramDatabase + + + Disabled + ..\..\include;..\..;%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + ..\..\include;..\..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_VARIADIC_MAX=10;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + + + ..\..\include;..\..;%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded @@ -73,10 +134,12 @@ $(GTestDir);%(AdditionalIncludeDirectories) + $(GTestDir);%(AdditionalIncludeDirectories) $(GTestDir);%(AdditionalIncludeDirectories) + $(GTestDir);%(AdditionalIncludeDirectories) - + \ No newline at end of file diff --git a/googlemock/msvc/2010/gmock_config.props b/googlemock/msvc/2010/gmock_config.props index 441f31cf..017d710b 100644 --- a/googlemock/msvc/2010/gmock_config.props +++ b/googlemock/msvc/2010/gmock_config.props @@ -1,4 +1,4 @@ - + ../../../googletest @@ -16,4 +16,4 @@ $(GTestDir) - + \ No newline at end of file diff --git a/googlemock/msvc/2010/gmock_main.vcxproj b/googlemock/msvc/2010/gmock_main.vcxproj index 27fecd5f..43da043d 100644 --- a/googlemock/msvc/2010/gmock_main.vcxproj +++ b/googlemock/msvc/2010/gmock_main.vcxproj @@ -1,14 +1,22 @@ - + Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589} @@ -20,10 +28,23 @@ StaticLibrary Unicode true + v100 + + + StaticLibrary + Unicode + true + v100 StaticLibrary Unicode + v100 + + + StaticLibrary + Unicode + v100 @@ -32,23 +53,39 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + Disabled ../../include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_VARIADIC_MAX=10;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -58,10 +95,34 @@ ProgramDatabase + + + Disabled + ../../include;%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + ../../include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_VARIADIC_MAX=10;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + + + ../../include;%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded @@ -79,10 +140,12 @@ ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) - + \ No newline at end of file diff --git a/googlemock/msvc/2010/gmock_test.vcxproj b/googlemock/msvc/2010/gmock_test.vcxproj index 265439ec..dcbeb587 100644 --- a/googlemock/msvc/2010/gmock_test.vcxproj +++ b/googlemock/msvc/2010/gmock_test.vcxproj @@ -1,14 +1,22 @@ - + Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2} @@ -20,10 +28,23 @@ Application Unicode true + v100 + + + Application + Unicode + true + v100 Application Unicode + v100 + + + Application + Unicode + v100 @@ -32,26 +53,44 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ true - $(SolutionDir)$(Configuration)\ + true + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ false + false + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ /bigobj %(AdditionalOptions) Disabled - ..\..\include;..\..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -66,11 +105,29 @@ MachineX86 + + + /bigobj %(AdditionalOptions) + Disabled + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + true + Console + + /bigobj %(AdditionalOptions) - ..\..\include;..\..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) MultiThreaded @@ -85,6 +142,24 @@ MachineX86 + + + /bigobj %(AdditionalOptions) + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;_VARIADIC_MAX=10;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + true + Console + true + true + + {e4ef614b-30df-4954-8c53-580a0bf6b589} @@ -98,4 +173,4 @@ - + \ No newline at end of file -- cgit v1.2.3 From cb8ebf5c9a04e90e338483878e0cdb8f3fbaf6e1 Mon Sep 17 00:00:00 2001 From: Arkady Shapkin Date: Tue, 22 Aug 2017 00:13:23 +0300 Subject: Support x64 configuration for old VS2015 projects --- googlemock/msvc/2015/gmock.sln | 14 ++++++ googlemock/msvc/2015/gmock.vcxproj | 65 ++++++++++++++++++++++++++- googlemock/msvc/2015/gmock_main.vcxproj | 65 ++++++++++++++++++++++++++- googlemock/msvc/2015/gmock_test.vcxproj | 79 +++++++++++++++++++++++++++++++-- 4 files changed, 216 insertions(+), 7 deletions(-) (limited to 'googlemock') diff --git a/googlemock/msvc/2015/gmock.sln b/googlemock/msvc/2015/gmock.sln index c59e07fc..d4203a84 100644 --- a/googlemock/msvc/2015/gmock.sln +++ b/googlemock/msvc/2015/gmock.sln @@ -10,21 +10,35 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.ActiveCfg = Debug|Win32 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.Build.0 = Debug|Win32 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|x64.ActiveCfg = Debug|x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|x64.Build.0 = Debug|x64 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.ActiveCfg = Release|Win32 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.Build.0 = Release|Win32 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|x64.ActiveCfg = Release|x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|x64.Build.0 = Release|x64 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.ActiveCfg = Debug|Win32 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.Build.0 = Debug|Win32 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|x64.ActiveCfg = Debug|x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|x64.Build.0 = Debug|x64 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.ActiveCfg = Release|Win32 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.Build.0 = Release|Win32 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|x64.ActiveCfg = Release|x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|x64.Build.0 = Release|x64 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.ActiveCfg = Debug|Win32 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.Build.0 = Debug|Win32 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|x64.ActiveCfg = Debug|x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|x64.Build.0 = Debug|x64 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.ActiveCfg = Release|Win32 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.Build.0 = Release|Win32 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|x64.ActiveCfg = Release|x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/googlemock/msvc/2015/gmock.vcxproj b/googlemock/msvc/2015/gmock.vcxproj index d5ddd091..c6b56e61 100644 --- a/googlemock/msvc/2015/gmock.vcxproj +++ b/googlemock/msvc/2015/gmock.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5} @@ -22,11 +30,22 @@ true v140 + + StaticLibrary + Unicode + true + v140 + StaticLibrary Unicode v140 + + StaticLibrary + Unicode + v140 + @@ -34,18 +53,34 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + Disabled @@ -60,6 +95,19 @@ ProgramDatabase + + + Disabled + ..\..\include;..\..;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + ..\..\include;..\..;%(AdditionalIncludeDirectories) @@ -71,11 +119,24 @@ ProgramDatabase + + + ..\..\include;..\..;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + $(GTestDir);%(AdditionalIncludeDirectories) + $(GTestDir);%(AdditionalIncludeDirectories) $(GTestDir);%(AdditionalIncludeDirectories) + $(GTestDir);%(AdditionalIncludeDirectories) diff --git a/googlemock/msvc/2015/gmock_main.vcxproj b/googlemock/msvc/2015/gmock_main.vcxproj index 76cc68b9..42381dfa 100644 --- a/googlemock/msvc/2015/gmock_main.vcxproj +++ b/googlemock/msvc/2015/gmock_main.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589} @@ -22,11 +30,22 @@ true v140 + + StaticLibrary + Unicode + true + v140 + StaticLibrary Unicode v140 + + StaticLibrary + Unicode + v140 + @@ -34,18 +53,34 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + Disabled @@ -60,6 +95,19 @@ ProgramDatabase + + + Disabled + ../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + ../../include;%(AdditionalIncludeDirectories) @@ -71,6 +119,17 @@ ProgramDatabase + + + ../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + {34681f0d-ce45-415d-b5f2-5c662dfe3bd5} @@ -81,7 +140,9 @@ ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) diff --git a/googlemock/msvc/2015/gmock_test.vcxproj b/googlemock/msvc/2015/gmock_test.vcxproj index 76ea5534..01d1f201 100644 --- a/googlemock/msvc/2015/gmock_test.vcxproj +++ b/googlemock/msvc/2015/gmock_test.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2} @@ -22,11 +30,22 @@ true v140 + + Application + Unicode + true + v140 + Application Unicode v140 + + Application + Unicode + v140 + @@ -34,19 +53,37 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ true - $(SolutionDir)$(Configuration)\ + true + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ false + false + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ @@ -68,10 +105,28 @@ MachineX86 + + + /bigobj %(AdditionalOptions) + Disabled + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + true + Console + + /bigobj %(AdditionalOptions) - ..\..\include;..\..;%(AdditionalIncludeDirectories) + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) MultiThreaded @@ -87,6 +142,24 @@ MachineX86 + + + /bigobj %(AdditionalOptions) + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + true + Console + true + true + + {e4ef614b-30df-4954-8c53-580a0bf6b589} -- cgit v1.2.3 From fa5d3b3845aa4cc38eef41c2e7ba0e98bfe15b39 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Mon, 28 Aug 2017 16:13:41 -0400 Subject: Applying lint checks from upstream google3 --- googlemock/test/gmock-spec-builders_test.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'googlemock') diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 34088de1..c649bfd9 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -714,13 +714,14 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { } std::string warning_output = GetCapturedStdout(); EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); - EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", + warning_output); testing::GMOCK_FLAG(default_mock_behavior) = kFail; EXPECT_NONFATAL_FAILURE({ MockA a; a.DoA(0); - },"Uninteresting mock function call"); + }, "Uninteresting mock function call"); // Out of bounds values are converted to kWarn testing::GMOCK_FLAG(default_mock_behavior) = -1; @@ -731,7 +732,8 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { } warning_output = GetCapturedStdout(); EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); - EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", + warning_output); testing::GMOCK_FLAG(default_mock_behavior) = 3; CaptureStdout(); { @@ -740,7 +742,8 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { } warning_output = GetCapturedStdout(); EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); - EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", + warning_output); testing::GMOCK_FLAG(default_mock_behavior) = original_behavior; } -- cgit v1.2.3 From 29c07aa9dbeb622a6f8f0d1d07c9f139e18b5dca Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 21:19:45 +0200 Subject: remove Yob's comma mentioned in issue #1105 --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 6ea7f3a9..fa2d2fd0 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -148,7 +148,7 @@ Note that the mock class doesn't define `AppendPacket()`, unlike the real class. That's fine as long as the test doesn't need to call it. Next, you need a way to say that you want to use -`ConcretePacketStream` in production code, and use `MockPacketStream` +`ConcretePacketStream` in production code and to use `MockPacketStream` in tests. Since the functions are not virtual and the two classes are unrelated, you must specify your choice at _compile time_ (as opposed to run time). -- cgit v1.2.3 From bb8399e1baf9d984894a54ba1e6e9e4d20c11a35 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 21:20:46 +0200 Subject: use plural verb as mentioned in issue #1105 --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index fa2d2fd0..753c6dd3 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -706,7 +706,7 @@ type `m` accepts): 1. When both `T` and `U` are built-in arithmetic types (`bool`, integers, and floating-point numbers), the conversion from `T` to `U` is not lossy (in other words, any value representable by `T` can also be represented by `U`); and 1. When `U` is a reference, `T` must also be a reference (as the underlying matcher may be interested in the address of the `U` value). -The code won't compile if any of these conditions isn't met. +The code won't compile if any of these conditions aren't met. Here's one example: -- cgit v1.2.3