From 09fd5b3ebfaac10b78bda664ec7f57fac74ef214 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 15 May 2017 17:07:03 -0400 Subject: Use std::string and ::string explicitly in gtest and gmock code. This merges a Google-internal change (117235625). Original CL description: This CL was created manually in about an hour with sed, a Python script to find all the places unqualified 'string' was mentioned, and some help from Emacs to add the "std::" qualifications, plus a few manual tweaks. --- googlemock/src/gmock-spec-builders.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'googlemock/src/gmock-spec-builders.cc') diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 95513420..2fa1ee4b 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -58,16 +58,15 @@ GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_gmock_mutex); // Logs a message including file and line number information. GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity, const char* file, int line, - const string& message) { + const std::string& message) { ::std::ostringstream s; s << file << ":" << line << ": " << message << ::std::endl; Log(severity, s.str(), 0); } // Constructs an ExpectationBase object. -ExpectationBase::ExpectationBase(const char* a_file, - int a_line, - const string& a_source_text) +ExpectationBase::ExpectationBase(const char* a_file, int a_line, + const std::string& a_source_text) : file_(a_file), line_(a_line), source_text_(a_source_text), @@ -244,7 +243,7 @@ GTEST_API_ ThreadLocal g_gmock_implicit_sequence; // Reports an uninteresting call (whose description is in msg) in the // manner specified by 'reaction'. -void ReportUninterestingCall(CallReaction reaction, const string& msg) { +void ReportUninterestingCall(CallReaction reaction, const std::string& msg) { // Include a stack trace only if --gmock_verbose=info is specified. const int stack_frames_to_skip = GMOCK_FLAG(verbose) == kInfoVerbosity ? 3 : -1; -- cgit v1.2.3 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/src/gmock-spec-builders.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'googlemock/src/gmock-spec-builders.cc') 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 -- 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/src/gmock-spec-builders.cc') 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 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'googlemock/src/gmock-spec-builders.cc') 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]; } -- cgit v1.2.3