diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-07-01 19:04:51 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-07-01 19:04:51 +0000 |
commit | 41b9b0b5614588d252d565646ae43e9607d46502 (patch) | |
tree | d5f7c699eab323243a6ac854e1d1fb77cc22cf0b /src | |
parent | 4019819dbb5369b1d638503523a04aaf7eb2a5ad (diff) | |
download | googletest-41b9b0b5614588d252d565646ae43e9607d46502.tar.gz googletest-41b9b0b5614588d252d565646ae43e9607d46502.tar.bz2 googletest-41b9b0b5614588d252d565646ae43e9607d46502.zip |
Implements Expectation, ExpectationSet, and After for specifying expectation orders.
Diffstat (limited to 'src')
-rw-r--r-- | src/gmock-spec-builders.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/gmock-spec-builders.cc b/src/gmock-spec-builders.cc index 465e4d63..00d16918 100644 --- a/src/gmock-spec-builders.cc +++ b/src/gmock-spec-builders.cc @@ -82,11 +82,9 @@ void ExpectationBase::RetireAllPreRequisites() { return; } - for (ExpectationBaseSet::const_iterator it = - immediate_prerequisites_.begin(); - it != immediate_prerequisites_.end(); - ++it) { - ExpectationBase* const prerequisite = (*it).get(); + for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin(); + it != immediate_prerequisites_.end(); ++it) { + ExpectationBase* const prerequisite = it->expectation_base().get(); if (!prerequisite->is_retired()) { prerequisite->RetireAllPreRequisites(); prerequisite->Retire(); @@ -99,10 +97,10 @@ void ExpectationBase::RetireAllPreRequisites() { // L >= g_gmock_mutex bool ExpectationBase::AllPrerequisitesAreSatisfied() const { g_gmock_mutex.AssertHeld(); - for (ExpectationBaseSet::const_iterator it = immediate_prerequisites_.begin(); + for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin(); it != immediate_prerequisites_.end(); ++it) { - if (!(*it)->IsSatisfied() || - !(*it)->AllPrerequisitesAreSatisfied()) + if (!(it->expectation_base()->IsSatisfied()) || + !(it->expectation_base()->AllPrerequisitesAreSatisfied())) return false; } return true; @@ -111,21 +109,21 @@ bool ExpectationBase::AllPrerequisitesAreSatisfied() const { // Adds unsatisfied pre-requisites of this expectation to 'result'. // L >= g_gmock_mutex void ExpectationBase::FindUnsatisfiedPrerequisites( - ExpectationBaseSet* result) const { + ExpectationSet* result) const { g_gmock_mutex.AssertHeld(); - for (ExpectationBaseSet::const_iterator it = immediate_prerequisites_.begin(); + for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin(); it != immediate_prerequisites_.end(); ++it) { - if ((*it)->IsSatisfied()) { + if (it->expectation_base()->IsSatisfied()) { // If *it is satisfied and has a call count of 0, some of its // pre-requisites may not be satisfied yet. - if ((*it)->call_count_ == 0) { - (*it)->FindUnsatisfiedPrerequisites(result); + if (it->expectation_base()->call_count_ == 0) { + it->expectation_base()->FindUnsatisfiedPrerequisites(result); } } else { // Now that we know *it is unsatisfied, we are not so interested // in whether its pre-requisites are satisfied. Therefore we // don't recursively call FindUnsatisfiedPrerequisites() here. - result->insert(*it); + *result += *it; } } } @@ -421,11 +419,11 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj) { } // Adds an expectation to a sequence. -void Sequence::AddExpectation( - const internal::linked_ptr<internal::ExpectationBase>& expectation) const { +void Sequence::AddExpectation(const Expectation& expectation) const { if (*last_expectation_ != expectation) { - if (*last_expectation_ != NULL) { - expectation->immediate_prerequisites_.insert(*last_expectation_); + if (last_expectation_->expectation_base() != NULL) { + expectation.expectation_base()->immediate_prerequisites_ + += *last_expectation_; } *last_expectation_ = expectation; } |