diff options
Diffstat (limited to 'googlemock/src')
-rw-r--r-- | googlemock/src/gmock-spec-builders.cc | 41 | ||||
-rw-r--r-- | googlemock/src/gmock.cc | 12 |
2 files changed, 25 insertions, 28 deletions
diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index b93f4e0..1a8def4 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -296,12 +296,12 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) { stack_frames_to_skip); break; default: // FAIL - Expect(false, NULL, -1, msg); + Expect(false, nullptr, -1, msg); } } UntypedFunctionMockerBase::UntypedFunctionMockerBase() - : mock_obj_(NULL), name_("") {} + : mock_obj_(nullptr), name_("") {} UntypedFunctionMockerBase::~UntypedFunctionMockerBase() {} @@ -340,7 +340,7 @@ const void* UntypedFunctionMockerBase::MockObject() const // We protect mock_obj_ under g_gmock_mutex in case this mock // function is called from two threads concurrently. MutexLock l(&g_gmock_mutex); - Assert(mock_obj_ != NULL, __FILE__, __LINE__, + Assert(mock_obj_ != nullptr, __FILE__, __LINE__, "MockObject() must not be called before RegisterOwner() or " "SetOwnerAndName() has been called."); mock_obj = mock_obj_; @@ -357,7 +357,7 @@ const char* UntypedFunctionMockerBase::Name() const // We protect name_ under g_gmock_mutex in case this mock // function is called from two threads concurrently. MutexLock l(&g_gmock_mutex); - Assert(name_ != NULL, __FILE__, __LINE__, + Assert(name_ != nullptr, __FILE__, __LINE__, "Name() must not be called before SetOwnerAndName() has " "been called."); name = name_; @@ -414,8 +414,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith( this->UntypedPerformDefaultAction(untyped_args, ss.str()); // Prints the function result. - if (result != NULL) - result->PrintAsActionResult(&ss); + if (result != nullptr) result->PrintAsActionResult(&ss); ReportUninterestingCall(reaction, ss.str()); return result; @@ -425,7 +424,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith( ::std::stringstream ss; ::std::stringstream why; ::std::stringstream loc; - const void* untyped_action = NULL; + const void* untyped_action = nullptr; // The UntypedFindMatchingExpectation() function acquires and // releases g_gmock_mutex. @@ -433,7 +432,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith( this->UntypedFindMatchingExpectation( untyped_args, &untyped_action, &is_excessive, &ss, &why); - const bool found = untyped_expectation != NULL; + const bool found = untyped_expectation != nullptr; // True iff we need to print the call's arguments and return value. // This definition must be kept in sync with the uses of Expect() @@ -442,10 +441,9 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith( !found || is_excessive || LogIsVisible(kInfo); if (!need_to_report_call) { // Perform the action without printing the call information. - return - untyped_action == NULL ? - this->UntypedPerformDefaultAction(untyped_args, "") : - this->UntypedPerformAction(untyped_action, untyped_args); + return untyped_action == nullptr + ? this->UntypedPerformDefaultAction(untyped_args, "") + : this->UntypedPerformAction(untyped_action, untyped_args); } ss << " Function call: " << Name(); @@ -458,16 +456,15 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith( } UntypedActionResultHolderBase* const result = - untyped_action == NULL ? - this->UntypedPerformDefaultAction(untyped_args, ss.str()) : - this->UntypedPerformAction(untyped_action, untyped_args); - if (result != NULL) - result->PrintAsActionResult(&ss); + untyped_action == nullptr + ? this->UntypedPerformDefaultAction(untyped_args, ss.str()) + : this->UntypedPerformAction(untyped_action, untyped_args); + if (result != nullptr) result->PrintAsActionResult(&ss); ss << "\n" << why.str(); if (!found) { // No expectation matches this call - reports a failure. - Expect(false, NULL, -1, ss.str()); + Expect(false, nullptr, -1, ss.str()); } else if (is_excessive) { // We had an upper-bound violation and the failure message is in ss. Expect(false, untyped_expectation->file(), @@ -568,7 +565,7 @@ typedef std::set<internal::UntypedFunctionMockerBase*> FunctionMockers; // expectations. struct MockObjectState { MockObjectState() - : first_used_file(NULL), first_used_line(-1), leakable(false) {} + : first_used_file(nullptr), first_used_line(-1), leakable(false) {} // Where in the source file an ON_CALL or EXPECT_CALL is first // invoked on this mock object. @@ -776,12 +773,12 @@ void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj, GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); MockObjectState& state = g_mock_object_registry.states()[mock_obj]; - if (state.first_used_file == NULL) { + if (state.first_used_file == nullptr) { state.first_used_file = file; state.first_used_line = line; const TestInfo* const test_info = UnitTest::GetInstance()->current_test_info(); - if (test_info != NULL) { + if (test_info != nullptr) { // FIXME: record the test case name when the // ON_CALL or EXPECT_CALL is invoked from SetUpTestCase() or // TearDownTestCase(). @@ -846,7 +843,7 @@ Expectation::~Expectation() {} // Adds an expectation to a sequence. void Sequence::AddExpectation(const Expectation& expectation) const { if (*last_expectation_ != expectation) { - if (last_expectation_->expectation_base() != NULL) { + if (last_expectation_->expectation_base() != nullptr) { expectation.expectation_base()->immediate_prerequisites_ += *last_expectation_; } diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc index 36356c9..675e8db 100644 --- a/googlemock/src/gmock.cc +++ b/googlemock/src/gmock.cc @@ -65,12 +65,12 @@ static const char* ParseGoogleMockFlagValue(const char* str, const char* flag, bool def_optional) { // str and flag must not be NULL. - if (str == NULL || flag == NULL) return NULL; + if (str == nullptr || flag == nullptr) return nullptr; // The flag must start with "--gmock_". const std::string flag_str = std::string("--gmock_") + flag; const size_t flag_len = flag_str.length(); - if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL; + if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr; // Skips the flag name. const char* flag_end = str + flag_len; @@ -83,7 +83,7 @@ static const char* ParseGoogleMockFlagValue(const char* str, // If def_optional is true and there are more characters after the // flag name, or if def_optional is false, there must be a '=' after // the flag name. - if (flag_end[0] != '=') return NULL; + if (flag_end[0] != '=') return nullptr; // Returns the string after "=". return flag_end + 1; @@ -100,7 +100,7 @@ static bool ParseGoogleMockBoolFlag(const char* str, const char* flag, const char* const value_str = ParseGoogleMockFlagValue(str, flag, true); // Aborts if the parsing failed. - if (value_str == NULL) return false; + if (value_str == nullptr) return false; // Converts the string value to a bool. *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F'); @@ -119,7 +119,7 @@ static bool ParseGoogleMockStringFlag(const char* str, const char* flag, const char* const value_str = ParseGoogleMockFlagValue(str, flag, false); // Aborts if the parsing failed. - if (value_str == NULL) return false; + if (value_str == nullptr) return false; // Sets *value to the value of the flag. *value = value_str; @@ -132,7 +132,7 @@ static bool ParseGoogleMockIntFlag(const char* str, const char* flag, const char* const value_str = ParseGoogleMockFlagValue(str, flag, true); // Aborts if the parsing failed. - if (value_str == NULL) return false; + if (value_str == nullptr) return false; // Sets *value to the value of the flag. return ParseInt32(Message() << "The value of flag --" << flag, |