MockCheckedExpectedCall* addFunctionToExpectationsList(const SimpleString& name) { MockCheckedExpectedCall* newCall = new MockCheckedExpectedCall; newCall->withName(name); expectationsList->addExpectedCall(newCall); return newCall; }
void MockSupport::expectNoCall(const SimpleString& functionName) { if (!enabled_) return; countCheck(); MockCheckedExpectedCall* call = new MockCheckedExpectedCall; call->withName(appendScopeToName(functionName)); unExpectations_.addExpectedCall(call); }
MockExpectedCall& MockSupport::expectOneCall(const SimpleString& functionName) { if (!enabled_) return MockIgnoredExpectedCall::instance(); MockCheckedExpectedCall* call = new MockCheckedExpectedCall; call->withName(functionName); if (strictOrdering_) call->withCallOrder(++expectedCallOrder_); expectations_.addExpectedCall(call); return *call; }
void checkUnexpectedNthCallMessage(unsigned int count, const char* expectedOrdinal) { MockExpectedCallsList callList; MockCheckedExpectedCall expCall; expCall.withName("bar"); for (unsigned int i = 0; i < (count - 1); i++) { expCall.callWasMade(1); callList.addExpectedCall(&expCall); } MockUnexpectedCallHappenedFailure failure(UtestShell::getCurrent(), "bar", callList); SimpleString expectedMessage = StringFromFormat("Mock Failure: Unexpected additional (%s) call to function: bar\n\tEXPECTED", expectedOrdinal); STRCMP_CONTAINS(expectedMessage.asCharString(), failure.getMessage().asCharString()); }
TEST(MockParameterTest, ignoreOtherParametersMultipleCallsButOneDidntHappen) { MockFailureReporterInstaller failureReporterInstaller; MockExpectedCallsListForTest expectations; MockCheckedExpectedCall* call = expectations.addFunction("boo"); call->ignoreOtherParameters(); call->callWasMade(1); call->parametersWereIgnored(); call->ignoreOtherParameters(); expectations.addFunction("boo")->ignoreOtherParameters(); MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); mock().expectOneCall("boo").ignoreOtherParameters(); mock().expectOneCall("boo").ignoreOtherParameters(); mock().actualCall("boo"); mock().checkExpectations(); CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); }