Skip to content

Expected calls matching several actual calls #1018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dae0892
Preparation of mock library in order to add support for expected call…
jgonzalezdr Jun 21, 2016
ed56f39
Basic implementation of "multi-matching" expectedCalls.
jgonzalezdr Jun 26, 2016
8ee564a
Added C language new calls for multi-matching expected calls.
jgonzalezdr Jun 26, 2016
0d2a162
Removed MockExpectedCallComposite.
jgonzalezdr Jun 26, 2016
e94cd93
Added test that checks that non-fulfilled calls have higher matching …
jgonzalezdr Jun 27, 2016
f42377e
When creating the list of potentially matching expected calls, non-fu…
jgonzalezdr Jun 27, 2016
162d117
Renamed MockExpectedCallsDidntHappenFailure to MockExpectedCallsNotFu…
jgonzalezdr Jun 27, 2016
94c5c69
Re-enabled strict ordering checks when the expected calls have no opt…
jgonzalezdr Jun 27, 2016
84593a9
Fixed declaration of MockExpectedCallsListForTest::addFunction to avo…
jgonzalezdr Jun 27, 2016
49f3b7d
Fixed declaration of call order related methods and attributes to use…
jgonzalezdr Jun 27, 2016
60828dc
Updated some unit tests and added a new one to improve code coverage.
jgonzalezdr Jun 28, 2016
a12e83b
Modified MockSupport::expectNoCall() method implementation to use a m…
jgonzalezdr Jun 28, 2016
6b5db95
Removed superfluous constructor and method in MockExpectedCall that w…
jgonzalezdr Jun 28, 2016
412ca5e
Fixed the mock scope not being properly reported when failing because…
jgonzalezdr Jun 30, 2016
a80efda
Added a class to store a queue of actual calls, needed to add a log o…
jgonzalezdr Jul 3, 2016
0f4623a
Modified MockCheckedActualCall to store a reference to its associated…
jgonzalezdr Jul 3, 2016
bc33181
Added functionality to MockCheckedActualCall and MockActualCallsQueue…
jgonzalezdr Jul 3, 2016
044a693
Added actual calls reporting to MockFailure, and preliminary non-func…
jgonzalezdr Jul 4, 2016
b3a20a4
Fixed compilation for Dos platform.
jgonzalezdr Jul 4, 2016
eb3aae1
Implemented a log of actual calls in MockSupport, such that mock fail…
jgonzalezdr Jul 5, 2016
fb5653f
Added functionality to MockSupport to limit the maximum size of the a…
jgonzalezdr Jul 5, 2016
3999548
Added C language new call for setMaxCallLogSize.
jgonzalezdr Jul 5, 2016
faf07f9
Added unit test for MockActualCallsList::hasFinalizedMatchingExpectat…
jgonzalezdr Jul 5, 2016
e912650
Improved unit test for MockSupport::setMaxCallLogSize().
jgonzalezdr Jul 7, 2016
111f0f0
Improved unit tests for MockExpectedCall.
jgonzalezdr Jul 7, 2016
ef47ef7
Removed old commented code that was left over.
jgonzalezdr Jul 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renamed MockExpectedCallsDidntHappenFailure to MockExpectedCallsNotFu…
…lfilledFailure.
  • Loading branch information
jgonzalezdr committed Jun 28, 2016
commit 162d117013d12855af7914b9143fd3fccf12bd68
4 changes: 2 additions & 2 deletions include/CppUTestExt/MockFailure.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class MockFailure : public TestFailure
void addExpectationsAndCallHistoryRelatedTo(const SimpleString& function, const MockExpectedCallsList& expectations);
};

class MockExpectedCallsDidntHappenFailure : public MockFailure
class MockExpectedCallsNotFulfilledFailure : public MockFailure
{
public:
MockExpectedCallsDidntHappenFailure(UtestShell* test, const MockExpectedCallsList& expectations);
MockExpectedCallsNotFulfilledFailure(UtestShell* test, const MockExpectedCallsList& expectations);
};

class MockUnexpectedCallHappenedFailure : public MockFailure
Expand Down
2 changes: 1 addition & 1 deletion src/CppUTestExt/MockFailure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void MockFailure::addExpectationsAndCallHistoryRelatedTo(const SimpleString& nam
message_ += expectationsForFunction.fulfilledCallsToString("\t\t");
}

MockExpectedCallsDidntHappenFailure::MockExpectedCallsDidntHappenFailure(UtestShell* test, const MockExpectedCallsList& expectations) : MockFailure(test)
MockExpectedCallsNotFulfilledFailure::MockExpectedCallsNotFulfilledFailure(UtestShell* test, const MockExpectedCallsList& expectations) : MockFailure(test)
{
message_ = "Mock Failure: Expected call WAS NOT fulfilled.\n";
addExpectationsAndCallHistory(expectations);
Expand Down
2 changes: 1 addition & 1 deletion src/CppUTestExt/MockSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void MockSupport::failTestWithExpectedCallsNotFulfilled()
if(getMockSupport(p))
expectationsList.addExpectations(getMockSupport(p)->expectations_);

MockExpectedCallsDidntHappenFailure failure(activeReporter_->getTestToFail(), expectationsList);
MockExpectedCallsNotFulfilledFailure failure(activeReporter_->getTestToFail(), expectationsList);
clear();
failTest(failure);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/CppUTestExt/MockCallTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TEST(MockCallTest, checkExpectationsClearsTheExpectations)

MockExpectedCallsListForTest expectations;
expectations.addFunction("foobar");
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectOneCall("foobar");
mock().checkExpectations();
Expand All @@ -104,7 +104,7 @@ TEST(MockCallTest, expectOneCallInScopeButNotHappen)

MockExpectedCallsListForTest expectations;
expectations.addFunction("scope::foobar");
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock("scope").expectOneCall("foobar");
mock().checkExpectations();
Expand Down Expand Up @@ -324,7 +324,7 @@ TEST(MockCallTest, ignoreOtherStillFailsIfExpectedOneDidntHappen)

MockExpectedCallsListForTest expectations;
expectations.addFunction("foo");
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectOneCall("foo");
mock().ignoreOtherCalls();
Expand Down Expand Up @@ -527,7 +527,7 @@ TEST(MockCallTest, expectNCalls_NotFulfilled)

MockExpectedCallsListForTest expectations;
expectations.addFunction(2, 2, "boo")->callWasMade(1);
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectNCalls(2, "boo");
mock().actualCall("boo");
Expand All @@ -542,7 +542,7 @@ TEST(MockCallTest, expectAtLeastOneCall_NotFulfilled)

MockExpectedCallsListForTest expectations;
expectations.addFunction(1, (unsigned int)-1, "boo");
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectAtLeastOneCall("boo");
mock().checkExpectations();
Expand All @@ -558,7 +558,7 @@ TEST(MockCallTest, expectAtLeastNCalls_NotFulfilled)
MockCheckedExpectedCall* expectedCall = expectations.addFunction(3, (unsigned int)-1, "boo");
expectedCall->callWasMade(1);
expectedCall->callWasMade(2);
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectAtLeastNCalls(3, "boo");
mock().actualCall("boo");
Expand Down Expand Up @@ -612,7 +612,7 @@ TEST(MockCallTest, expectRangeOfCalls_NotFulfilled_BelowMinimum)
MockExpectedCallsListForTest expectations;
MockCheckedExpectedCall* expectedCall = expectations.addFunction(2, 3, "boo");
expectedCall->callWasMade(1);
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectRangeOfCalls(2, 3, "boo");
mock().actualCall("boo");
Expand Down
4 changes: 2 additions & 2 deletions tests/CppUTestExt/MockComparatorCopierTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ TEST(MockComparatorCopierTest, customObjectWithFunctionComparatorThatFailsCovers

MockExpectedCallsListForTest expectations;
expectations.addFunction("function")->withParameterOfType("MyTypeForTesting", "parameterName", &object);
MockExpectedCallsDidntHappenFailure failure(UtestShell::getCurrent(), expectations);
MockExpectedCallsNotFulfilledFailure failure(UtestShell::getCurrent(), expectations);

mock().expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object);
mock().checkExpectations();
Expand Down Expand Up @@ -184,7 +184,7 @@ TEST(MockComparatorCopierTest, noActualCallForCustomTypeOutputParameter)

MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
mock().checkExpectations();
Expand Down
2 changes: 1 addition & 1 deletion tests/CppUTestExt/MockFailureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ TEST(MockFailureTest, expectedCallDidNotHappen)
call3->callWasMade(1);
addAllToList();

MockExpectedCallsDidntHappenFailure failure(UtestShell::getCurrent(), *list);
MockExpectedCallsNotFulfilledFailure failure(UtestShell::getCurrent(), *list);
STRCMP_EQUAL("Mock Failure: Expected call WAS NOT fulfilled.\n"
"\tEXPECTED calls that WERE NOT fulfilled:\n"
"\t\tfoobar -> no parameters (expected 1 call, but was called 0 times)\n"
Expand Down
2 changes: 1 addition & 1 deletion tests/CppUTestExt/MockHierarchyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ TEST(MockHierarchyTest, checkExpectationsWorksHierarchically)
MockExpectedCallsListForTest expectations;
expectations.addFunction("first::foobar");
expectations.addFunction("second::helloworld");
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock("first").expectOneCall("foobar");
mock("second").expectOneCall("helloworld");
Expand Down
4 changes: 2 additions & 2 deletions tests/CppUTestExt/MockParameterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ TEST(MockParameterTest, ignoreOtherParametersMultipleCallsButOneDidntHappen)
call->finalizeActualCallMatch();
call->ignoreOtherParameters();
expectations.addFunction("boo")->ignoreOtherParameters();
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().expectOneCall("boo").ignoreOtherParameters();
mock().expectOneCall("boo").ignoreOtherParameters();
Expand Down Expand Up @@ -492,7 +492,7 @@ TEST(MockParameterTest, noActualCallForOutputParameter)
mock().expectOneCall("foo").withOutputParameterReturning("output", &output, sizeof(output));

expectations.addFunction("foo")->withOutputParameterReturning("output", &output, sizeof(output));
MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(mockFailureTest(), expectations);

mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
Expand Down
2 changes: 1 addition & 1 deletion tests/CppUTestExt/MockPluginTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TEST(MockPlugin, checkExpectationsAndClearAtEnd)

MockExpectedCallsListForTest expectations;
expectations.addFunction("foobar");
MockExpectedCallsDidntHappenFailure expectedFailure(test, expectations);
MockExpectedCallsNotFulfilledFailure expectedFailure(test, expectations);

mock().expectOneCall("foobar");

Expand Down