@@ -50,9 +50,9 @@ SimpleString MockCheckedActualCall::getName() const
5050}
5151
5252MockCheckedActualCall::MockCheckedActualCall (int callOrder, MockFailureReporter* reporter, const MockExpectedCallsList& allExpectations)
53- : callOrder_(callOrder), reporter_(reporter), state_(CALL_SUCCEED), fulfilledExpectation_ (NULL ), allExpectations_(allExpectations), outputParameterExpectations_(NULL )
53+ : callOrder_(callOrder), reporter_(reporter), state_(CALL_SUCCEED), matchingExpectation_ (NULL ), allExpectations_(allExpectations), outputParameterExpectations_(NULL )
5454{
55- unfulfilledExpectations_. addUnfulfilledExpectations (allExpectations);
55+ potentiallyMatchingExpectations_. addPotentiallyMatchingExpectations (allExpectations);
5656}
5757
5858MockCheckedActualCall::~MockCheckedActualCall ()
@@ -78,7 +78,7 @@ void MockCheckedActualCall::failTest(const MockFailure& failure)
7878 }
7979}
8080
81- void MockCheckedActualCall::finalizeOutputParameters (MockCheckedExpectedCall* expectedCall)
81+ void MockCheckedActualCall::copyOutputParameters (MockCheckedExpectedCall* expectedCall)
8282{
8383 for (MockOutputParametersListNode* p = outputParameterExpectations_; p; p = p->next_ )
8484 {
@@ -103,19 +103,19 @@ void MockCheckedActualCall::finalizeOutputParameters(MockCheckedExpectedCall* ex
103103 }
104104}
105105
106- void MockCheckedActualCall::finalizeCallWhenFulfilled ()
106+ void MockCheckedActualCall::completeCallWhenMatchIsFound ()
107107{
108- // Expectations that don't ignore parameters have higher fulfillment preference than those that ignore parameters
108+ // Expectations that don't ignore parameters have higher fulfillment preference than those that ignore parameters
109109
110- fulfilledExpectation_ = unfulfilledExpectations_. removeOneFulfilledExpectation ();
111- if (fulfilledExpectation_ ) {
112- finalizeOutputParameters (fulfilledExpectation_ );
110+ matchingExpectation_ = potentiallyMatchingExpectations_. removeFirstFinalizedMatchingExpectation ();
111+ if (matchingExpectation_ ) {
112+ copyOutputParameters (matchingExpectation_ );
113113 callHasSucceeded ();
114114 } else {
115- MockCheckedExpectedCall* fulfilledExpectationWithIgnoredParameters = unfulfilledExpectations_. getOneFulfilledExpectationWithIgnoredParameters ();
116- if (fulfilledExpectationWithIgnoredParameters ) {
117- finalizeOutputParameters (fulfilledExpectationWithIgnoredParameters );
118- }
115+ MockCheckedExpectedCall* matchingExpectationWithIgnoredParameters = potentiallyMatchingExpectations_. getFirstMatchingExpectation ();
116+ if (matchingExpectationWithIgnoredParameters ) {
117+ copyOutputParameters (matchingExpectationWithIgnoredParameters );
118+ }
119119 }
120120}
121121
@@ -127,29 +127,28 @@ void MockCheckedActualCall::callHasSucceeded()
127127void MockCheckedActualCall::callIsInProgress ()
128128{
129129 setState (CALL_IN_PROGRESS);
130- if (fulfilledExpectation_ )
130+ if (matchingExpectation_ )
131131 {
132- fulfilledExpectation_-> resetExpectation ();
133- fulfilledExpectation_ = NULL ;
132+ matchingExpectation_-> resetActualCallMatchingState ();
133+ matchingExpectation_ = NULL ;
134134 }
135- unfulfilledExpectations_. onlyKeepUnfulfilledExpectations ();
135+ potentiallyMatchingExpectations_. onlyKeepUnmatchingExpectations ();
136136}
137137
138138MockActualCall& MockCheckedActualCall::withName (const SimpleString& name)
139139{
140140 setName (name);
141141 callIsInProgress ();
142142
143- unfulfilledExpectations_ .onlyKeepExpectationsRelatedTo (name);
144- if (unfulfilledExpectations_ .isEmpty ()) {
143+ potentiallyMatchingExpectations_ .onlyKeepExpectationsRelatedTo (name);
144+ if (potentiallyMatchingExpectations_ .isEmpty ()) {
145145 MockUnexpectedCallHappenedFailure failure (getTest (), name, allExpectations_);
146146 failTest (failure);
147147 return *this ;
148148 }
149149
150- unfulfilledExpectations_.callWasMade (callOrder_);
151-
152- finalizeCallWhenFulfilled ();
150+ potentiallyMatchingExpectations_.callWasMade (callOrder_);
151+ completeCallWhenMatchIsFound ();
153152
154153 return *this ;
155154}
@@ -168,16 +167,16 @@ void MockCheckedActualCall::checkInputParameter(const MockNamedValue& actualPara
168167
169168 callIsInProgress ();
170169
171- unfulfilledExpectations_ .onlyKeepExpectationsWithInputParameter (actualParameter);
170+ potentiallyMatchingExpectations_ .onlyKeepExpectationsWithInputParameter (actualParameter);
172171
173- if (unfulfilledExpectations_ .isEmpty ()) {
172+ if (potentiallyMatchingExpectations_ .isEmpty ()) {
174173 MockUnexpectedInputParameterFailure failure (getTest (), getName (), actualParameter, allExpectations_);
175174 failTest (failure);
176175 return ;
177176 }
178177
179- unfulfilledExpectations_ .parameterWasPassed (actualParameter.getName ());
180- finalizeCallWhenFulfilled ();
178+ potentiallyMatchingExpectations_ .parameterWasPassed (actualParameter.getName ());
179+ completeCallWhenMatchIsFound ();
181180}
182181
183182void MockCheckedActualCall::checkOutputParameter (const MockNamedValue& outputParameter)
@@ -189,16 +188,16 @@ void MockCheckedActualCall::checkOutputParameter(const MockNamedValue& outputPar
189188
190189 callIsInProgress ();
191190
192- unfulfilledExpectations_ .onlyKeepExpectationsWithOutputParameter (outputParameter);
191+ potentiallyMatchingExpectations_ .onlyKeepExpectationsWithOutputParameter (outputParameter);
193192
194- if (unfulfilledExpectations_ .isEmpty ()) {
193+ if (potentiallyMatchingExpectations_ .isEmpty ()) {
195194 MockUnexpectedOutputParameterFailure failure (getTest (), getName (), outputParameter, allExpectations_);
196195 failTest (failure);
197196 return ;
198197 }
199198
200- unfulfilledExpectations_ .outputParameterWasPassed (outputParameter.getName ());
201- finalizeCallWhenFulfilled ();
199+ potentiallyMatchingExpectations_ .outputParameterWasPassed (outputParameter.getName ());
200+ completeCallWhenMatchIsFound ();
202201}
203202
204203MockActualCall& MockCheckedActualCall::withBoolParameter (const SimpleString& name, bool value)
@@ -339,21 +338,22 @@ void MockCheckedActualCall::checkExpectations()
339338{
340339 if (state_ != CALL_IN_PROGRESS)
341340 {
342- unfulfilledExpectations_. resetExpectations ();
341+ potentiallyMatchingExpectations_. resetActualCallMatchingState ();
343342 return ;
344343 }
345344
346- if (! unfulfilledExpectations_. hasUnfulfilledExpectations ())
347- FAIL (" Actual call is in progress. Checking expectations. But no unfulfilled expectations. Cannot happen." ) // LCOV_EXCL_LINE
345+ if (potentiallyMatchingExpectations_. hasFinalizedMatchingExpectations ())
346+ FAIL (" Actual call is in progress, but there are finalized matching expectations when checking expectations. This cannot happen." ) // LCOV_EXCL_LINE
348347
349- fulfilledExpectation_ = unfulfilledExpectations_.removeOneFulfilledExpectationWithIgnoredParameters ();
350- if (fulfilledExpectation_) {
348+ matchingExpectation_ = potentiallyMatchingExpectations_.removeFirstMatchingExpectation ();
349+ if (matchingExpectation_) {
350+ matchingExpectation_->finalizeActualCallMatch ();
351351 callHasSucceeded ();
352- unfulfilledExpectations_. resetExpectations ();
352+ potentiallyMatchingExpectations_. resetActualCallMatchingState ();
353353 return ;
354354 }
355355
356- if (unfulfilledExpectations_. hasUnfulfilledExpectationsBecauseOfMissingParameters ()) {
356+ if (potentiallyMatchingExpectations_. hasUnmatchingExpectationsBecauseOfMissingParameters ()) {
357357 MockExpectedParameterDidntHappenFailure failure (getTest (), getName (), allExpectations_);
358358 failTest (failure);
359359 }
@@ -371,8 +371,8 @@ void MockCheckedActualCall::setState(ActualCallState state)
371371MockNamedValue MockCheckedActualCall::returnValue ()
372372{
373373 checkExpectations ();
374- if (fulfilledExpectation_ )
375- return fulfilledExpectation_ ->returnValue ();
374+ if (matchingExpectation_ )
375+ return matchingExpectation_ ->returnValue ();
376376 return MockNamedValue (" no return value" );
377377}
378378
@@ -513,19 +513,23 @@ bool MockCheckedActualCall::hasReturnValue()
513513
514514MockActualCall& MockCheckedActualCall::onObject (const void * objectPtr)
515515{
516+ if (hasFailed ()) {
517+ return *this ;
518+ }
519+
516520 callIsInProgress ();
517521
518- unfulfilledExpectations_ .onlyKeepExpectationsOnObject (objectPtr);
522+ potentiallyMatchingExpectations_ .onlyKeepExpectationsOnObject (objectPtr);
519523
520- if (unfulfilledExpectations_ .isEmpty ()) {
524+ if (potentiallyMatchingExpectations_ .isEmpty ()) {
521525 MockUnexpectedObjectFailure failure (getTest (), getName (), objectPtr, allExpectations_);
522526 failTest (failure);
523527 return *this ;
524528 }
525529
526- unfulfilledExpectations_.wasPassedToObject ();
530+ potentiallyMatchingExpectations_.wasPassedToObject ();
531+ completeCallWhenMatchIsFound ();
527532
528- finalizeCallWhenFulfilled ();
529533 return *this ;
530534}
531535
0 commit comments