From 67a240a107888c0d3baba528f05820dcc8ac737f Mon Sep 17 00:00:00 2001 From: Jonathan Wendeborn Date: Tue, 16 Oct 2018 08:07:15 +0200 Subject: Added Mock::IsNaggy, IsNice, and IsStrict --- googlemock/src/gmock-spec-builders.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 95513420..0813a974 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -707,6 +707,35 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj) return expectations_met; } +namespace { +// checks whether the specified mock_obj has a registered call reaction +bool HasCallReaction(void* mock_obj, internal::CallReaction reaction) { + using internal::CallReaction; + + const auto found = g_uninteresting_call_reaction.find(mock_obj); + if (found == g_uninteresting_call_reaction.cend()) { + return internal::CallReaction::kDefault == reaction; + } + return found->second == reaction; +} +} + +bool Mock::IsNaggy(void* mock_obj) + GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { + internal::MutexLock l(&internal::g_gmock_mutex); + return HasCallReaction(mock_obj, internal::CallReaction::kWarn); +} +bool Mock::IsNice(void* mock_obj) + GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { + internal::MutexLock l(&internal::g_gmock_mutex); + return HasCallReaction(mock_obj, internal::CallReaction::kAllow); +} +bool Mock::IsStrict(void* mock_obj) + GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { + internal::MutexLock l(&internal::g_gmock_mutex); + return HasCallReaction(mock_obj, internal::CallReaction::kFail); +} + // Registers a mock object and a mock method it owns. void Mock::Register(const void* mock_obj, internal::UntypedFunctionMockerBase* mocker) -- cgit v1.2.3 From 6bbf911a8dc0c42ad05135f26a07f4893eb83916 Mon Sep 17 00:00:00 2001 From: Jonathan Wendeborn Date: Tue, 16 Oct 2018 08:19:02 +0200 Subject: Don't fully qualify enum member --- googlemock/src/gmock-spec-builders.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 0813a974..408623da 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -710,11 +710,9 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj) namespace { // checks whether the specified mock_obj has a registered call reaction bool HasCallReaction(void* mock_obj, internal::CallReaction reaction) { - using internal::CallReaction; - const auto found = g_uninteresting_call_reaction.find(mock_obj); if (found == g_uninteresting_call_reaction.cend()) { - return internal::CallReaction::kDefault == reaction; + return internal::kDefault == reaction; } return found->second == reaction; } @@ -723,17 +721,17 @@ bool HasCallReaction(void* mock_obj, internal::CallReaction reaction) { bool Mock::IsNaggy(void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); - return HasCallReaction(mock_obj, internal::CallReaction::kWarn); + return HasCallReaction(mock_obj, internal::kWarn); } bool Mock::IsNice(void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); - return HasCallReaction(mock_obj, internal::CallReaction::kAllow); + return HasCallReaction(mock_obj, internal::kAllow); } bool Mock::IsStrict(void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); - return HasCallReaction(mock_obj, internal::CallReaction::kFail); + return HasCallReaction(mock_obj, internal::kFail); } // Registers a mock object and a mock method it owns. -- cgit v1.2.3 From 386391b0144201e0cf5f66d8ba1cb60a1076f673 Mon Sep 17 00:00:00 2001 From: Jonathan Wendeborn Date: Tue, 16 Oct 2018 08:37:45 +0200 Subject: Use existing Mock::GetReactionOnUninterestingCalls() --- googlemock/src/gmock-spec-builders.cc | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 408623da..5b0a8306 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -707,31 +707,17 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj) return expectations_met; } -namespace { -// checks whether the specified mock_obj has a registered call reaction -bool HasCallReaction(void* mock_obj, internal::CallReaction reaction) { - const auto found = g_uninteresting_call_reaction.find(mock_obj); - if (found == g_uninteresting_call_reaction.cend()) { - return internal::kDefault == reaction; - } - return found->second == reaction; -} -} - bool Mock::IsNaggy(void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - return HasCallReaction(mock_obj, internal::kWarn); + return Mock::GetReactionOnUninterestingCalls(mock_obj) == internal::kWarn; } bool Mock::IsNice(void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - return HasCallReaction(mock_obj, internal::kAllow); + return Mock::GetReactionOnUninterestingCalls(mock_obj) == internal::kAllow; } bool Mock::IsStrict(void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { - internal::MutexLock l(&internal::g_gmock_mutex); - return HasCallReaction(mock_obj, internal::kFail); + return Mock::GetReactionOnUninterestingCalls(mock_obj) == internal::kFail; } // Registers a mock object and a mock method it owns. -- cgit v1.2.3 From a50e4f05b3d84c6a014c59a24263328242cc8236 Mon Sep 17 00:00:00 2001 From: misterg Date: Wed, 24 Oct 2018 17:02:11 -0400 Subject: Googletest export Remove linked_ptr and use std::shared_ptr instead PiperOrigin-RevId: 218571466 --- googlemock/src/gmock-spec-builders.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 5c20ed14..c93b2b5d 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -38,6 +38,7 @@ #include #include // NOLINT #include +#include #include #include #include @@ -848,7 +849,7 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj) Expectation::Expectation() {} Expectation::Expectation( - const internal::linked_ptr& an_expectation_base) + const std::shared_ptr& an_expectation_base) : expectation_base_(an_expectation_base) {} Expectation::~Expectation() {} -- cgit v1.2.3 From b57c703963be1ca9749b902c49083beac56648aa Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 24 Oct 2018 22:04:43 -0400 Subject: Googletest export Remove linked_ptr and use std::shared_ptr instead PiperOrigin-RevId: 218618184 --- googlemock/src/gmock-spec-builders.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index c93b2b5d..5c20ed14 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -38,7 +38,6 @@ #include #include // NOLINT #include -#include #include #include #include @@ -849,7 +848,7 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj) Expectation::Expectation() {} Expectation::Expectation( - const std::shared_ptr& an_expectation_base) + const internal::linked_ptr& an_expectation_base) : expectation_base_(an_expectation_base) {} Expectation::~Expectation() {} -- cgit v1.2.3 From 3feffddd1e8381209a48c24587e36e030051499f Mon Sep 17 00:00:00 2001 From: Vadim Barkov Date: Sun, 28 Oct 2018 03:27:51 +0300 Subject: Replaced all NULLs with nullptr in googlemock --- googlemock/src/gmock-spec-builders.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 5c20ed14..0f8e8ca5 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -866,7 +866,7 @@ void Sequence::AddExpectation(const Expectation& expectation) const { // Creates the implicit sequence if there isn't one. InSequence::InSequence() { - if (internal::g_gmock_implicit_sequence.get() == NULL) { + if (internal::g_gmock_implicit_sequence.get() == nullptr) { internal::g_gmock_implicit_sequence.set(new Sequence); sequence_created_ = true; } else { @@ -879,7 +879,7 @@ InSequence::InSequence() { InSequence::~InSequence() { if (sequence_created_) { delete internal::g_gmock_implicit_sequence.get(); - internal::g_gmock_implicit_sequence.set(NULL); + internal::g_gmock_implicit_sequence.set(nullptr); } } -- cgit v1.2.3 From 80b43d900b8ed44e16b306682d47d73175cecc7f Mon Sep 17 00:00:00 2001 From: misterg Date: Mon, 29 Oct 2018 11:09:33 -0400 Subject: Googletest export Remove linked_ptr and use std::shared_ptr instead PiperOrigin-RevId: 219129336 --- googlemock/src/gmock-spec-builders.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 5c20ed14..c93b2b5d 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -38,6 +38,7 @@ #include #include // NOLINT #include +#include #include #include #include @@ -848,7 +849,7 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj) Expectation::Expectation() {} Expectation::Expectation( - const internal::linked_ptr& an_expectation_base) + const std::shared_ptr& an_expectation_base) : expectation_base_(an_expectation_base) {} Expectation::~Expectation() {} -- cgit v1.2.3 From 826656b25f62ed0a2fadc7c5dde303616e621c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Lind=C3=A9n?= Date: Sat, 10 Nov 2018 15:05:55 +0100 Subject: Remove workarounds for unsupported MSVC versions --- googlemock/src/gmock-spec-builders.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index e8b51f6c..5db774ed 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,15 +// to bool 'true' or 'false') for MSVC 15 #ifdef _MSC_VER -#if _MSC_VER <= 1900 +#if _MSC_VER == 1900 # pragma warning(push) # pragma warning(disable:4800) #endif @@ -887,7 +887,7 @@ InSequence::~InSequence() { } // namespace testing #ifdef _MSC_VER -#if _MSC_VER <= 1900 +#if _MSC_VER == 1900 # pragma warning(pop) #endif #endif -- cgit v1.2.3 From 8e86f67261649621baf39e8c4368ae224c2193f6 Mon Sep 17 00:00:00 2001 From: durandal Date: Thu, 15 Nov 2018 16:09:09 -0500 Subject: Googletest export Move the Matcher interface to googletest so I can use it to extend death test regex matching in a subsequent change. PiperOrigin-RevId: 221675910 --- googlemock/src/gmock-matchers.cc | 110 --------------------------------------- 1 file changed, 110 deletions(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc index f8ddff15..4a3f7af2 100644 --- a/googlemock/src/gmock-matchers.cc +++ b/googlemock/src/gmock-matchers.cc @@ -42,116 +42,6 @@ #include namespace testing { - -// Constructs a matcher that matches a const std::string& whose value is -// equal to s. -Matcher::Matcher(const std::string& s) { *this = Eq(s); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const std::string& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { - *this = Eq(static_cast(s)); -} -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a const std::string& whose value is -// equal to s. -Matcher::Matcher(const char* s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a std::string whose value is equal to -// s. -Matcher::Matcher(const std::string& s) { *this = Eq(s); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a std::string whose value is equal to -// s. -Matcher::Matcher(const ::string& s) { - *this = Eq(static_cast(s)); -} -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a std::string whose value is equal to -// s. -Matcher::Matcher(const char* s) { *this = Eq(std::string(s)); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const std::string& s) { - *this = Eq(static_cast<::string>(s)); -} - -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } - -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const char* s) { *this = Eq(::string(s)); } - -// Constructs a matcher that matches a ::string whose value is equal to s. -Matcher<::string>::Matcher(const std::string& s) { - *this = Eq(static_cast<::string>(s)); -} - -// Constructs a matcher that matches a ::string whose value is equal to s. -Matcher<::string>::Matcher(const ::string& s) { *this = Eq(s); } - -// Constructs a matcher that matches a string whose value is equal to s. -Matcher<::string>::Matcher(const char* s) { *this = Eq(::string(s)); } -#endif // GTEST_HAS_GLOBAL_STRING - -#if GTEST_HAS_ABSL -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(const std::string& s) { - *this = Eq(s); -} - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(const char* s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(absl::string_view s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(const std::string& s) { *this = Eq(s); } - -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } -#endif // GTEST_HAS_GLOBAL_STRING - -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(const char* s) { - *this = Eq(std::string(s)); -} - -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(absl::string_view s) { - *this = Eq(std::string(s)); -} -#endif // GTEST_HAS_ABSL - namespace internal { // Returns the description for a matcher defined using the MATCHER*() -- cgit v1.2.3 From b49266606875a8fa6cac79a05002d490a9a2af07 Mon Sep 17 00:00:00 2001 From: misterg Date: Mon, 19 Nov 2018 15:54:09 -0500 Subject: Googletest export Internal Change PiperOrigin-RevId: 222123106 --- googlemock/src/gmock-spec-builders.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 5db774ed..e832966f 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -291,7 +291,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) { "call should not happen. Do not suppress it by blindly adding " "an EXPECT_CALL() if you don't mean to enforce the call. " "See " - "https://github.com/google/googletest/blob/master/googlemock/" + "https://github.com/abseil/googletest/blob/master/googlemock/" "docs/CookBook.md#" "knowing-when-to-expect for details.\n", stack_frames_to_skip); -- cgit v1.2.3 From 26743363be8f579ee7d637e5b15cbf73e9e18a4a Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 3 Dec 2018 11:30:02 -0500 Subject: Googletest export Applied fixes for ClangTidy modernize-use-override and modernize-use-using. PiperOrigin-RevId: 223800219 --- googlemock/src/gmock-cardinalities.cc | 10 +++++----- googlemock/src/gmock-internal-utils.cc | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-cardinalities.cc b/googlemock/src/gmock-cardinalities.cc index 0549f727..7463f438 100644 --- a/googlemock/src/gmock-cardinalities.cc +++ b/googlemock/src/gmock-cardinalities.cc @@ -70,18 +70,18 @@ class BetweenCardinalityImpl : public CardinalityInterface { // Conservative estimate on the lower/upper bound of the number of // calls allowed. - virtual int ConservativeLowerBound() const { return min_; } - virtual int ConservativeUpperBound() const { return max_; } + int ConservativeLowerBound() const override { return min_; } + int ConservativeUpperBound() const override { return max_; } - virtual bool IsSatisfiedByCallCount(int call_count) const { + bool IsSatisfiedByCallCount(int call_count) const override { return min_ <= call_count && call_count <= max_; } - virtual bool IsSaturatedByCallCount(int call_count) const { + bool IsSaturatedByCallCount(int call_count) const override { return call_count >= max_; } - virtual void DescribeTo(::std::ostream* os) const; + void DescribeTo(::std::ostream* os) const override; private: const int min_; diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index e3a67485..937d830a 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -93,8 +93,8 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) { // use Google Mock with a testing framework other than Google Test. class GoogleTestFailureReporter : public FailureReporterInterface { public: - virtual void ReportFailure(FailureType type, const char* file, int line, - const std::string& message) { + void ReportFailure(FailureType type, const char* file, int line, + const std::string& message) override { AssertHelper(type == kFatal ? TestPartResult::kFatalFailure : TestPartResult::kNonFatalFailure, -- cgit v1.2.3 From 2c8ab3f18b2ed9fdc1742ec60b6e34248d04efe3 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Tue, 4 Dec 2018 21:44:39 -0600 Subject: feat: Add initial support for PlatformIO and Arduino --- googlemock/src/gmock_main.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc index a3a271e6..50d0b426 100644 --- a/googlemock/src/gmock_main.cc +++ b/googlemock/src/gmock_main.cc @@ -32,6 +32,20 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#ifdef ARDUINO +void setup() { + int argc = 0; + char** argv = nullptr; + // Since Google Mock depends on Google Test, InitGoogleMock() is + // also responsible for initializing Google Test. Therefore there's + // no need for calling testing::InitGoogleTest() separately. + testing::InitGoogleMock(&argc, argv); +} +void loop() { + RUN_ALL_TESTS(); +} +#else + // MS C++ compiler/linker has a bug on Windows (not on Windows CE), which // causes a link error when _tmain is defined in a static library and UNICODE // is enabled. For this reason instead of _tmain, main function is used on @@ -52,3 +66,5 @@ GTEST_API_ int main(int argc, char** argv) { testing::InitGoogleMock(&argc, argv); return RUN_ALL_TESTS(); } +#endif + -- cgit v1.2.3 From 81f00260668d1124df94eb1266163043882db0ca Mon Sep 17 00:00:00 2001 From: misterg Date: Wed, 12 Dec 2018 15:24:04 -0500 Subject: Googletest export Internal Change PiperOrigin-RevId: 225231727 --- googlemock/src/gmock-spec-builders.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googlemock/src') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index e832966f..5db774ed 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -291,7 +291,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) { "call should not happen. Do not suppress it by blindly adding " "an EXPECT_CALL() if you don't mean to enforce the call. " "See " - "https://github.com/abseil/googletest/blob/master/googlemock/" + "https://github.com/google/googletest/blob/master/googlemock/" "docs/CookBook.md#" "knowing-when-to-expect for details.\n", stack_frames_to_skip); -- cgit v1.2.3