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
Removed superfluous constructor and method in MockExpectedCall that w…
…here not being used in production code.
  • Loading branch information
jgonzalezdr committed Jun 28, 2016
commit 6b5db9522a22d63e899c9cc9cf375d76df25d7ba
3 changes: 0 additions & 3 deletions include/CppUTestExt/MockCheckedExpectedCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ class MockCheckedExpectedCall : public MockExpectedCall
{

public:
MockCheckedExpectedCall();
MockCheckedExpectedCall(unsigned int minCalls, unsigned int maxCalls);
virtual ~MockCheckedExpectedCall();

virtual MockExpectedCall& withName(const SimpleString& name) _override;
virtual MockExpectedCall& withCallOrder(unsigned int callOrder) _override { return withCallOrder(callOrder, callOrder); }
virtual MockExpectedCall& withCallOrder(unsigned int initialCallOrder, unsigned int finalCallOrder) _override;
virtual MockExpectedCall& withBoolParameter(const SimpleString& name, bool value) _override;
virtual MockExpectedCall& withIntParameter(const SimpleString& name, int value) _override;
Expand Down Expand Up @@ -146,7 +144,6 @@ class MockIgnoredExpectedCall: public MockExpectedCall
public:

virtual MockExpectedCall& withName(const SimpleString&) _override { return *this;}
virtual MockExpectedCall& withCallOrder(unsigned int) _override { return *this; }
virtual MockExpectedCall& withCallOrder(unsigned int, unsigned int) _override { return *this; }
virtual MockExpectedCall& withBoolParameter(const SimpleString&, bool) _override { return *this; }
virtual MockExpectedCall& withIntParameter(const SimpleString&, int) _override { return *this; }
Expand Down
1 change: 0 additions & 1 deletion include/CppUTestExt/MockExpectedCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class MockExpectedCall
virtual ~MockExpectedCall();

virtual MockExpectedCall& withName(const SimpleString& name)=0;
virtual MockExpectedCall& withCallOrder(unsigned int)=0;
virtual MockExpectedCall& withCallOrder(unsigned int, unsigned int)=0;
MockExpectedCall& withParameter(const SimpleString& name, bool value) { return withBoolParameter(name, value); }
MockExpectedCall& withParameter(const SimpleString& name, int value) { return withIntParameter(name, value); }
Expand Down
10 changes: 0 additions & 10 deletions src/CppUTestExt/MockExpectedCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ SimpleString MockCheckedExpectedCall::getName() const
return functionName_;
}

MockCheckedExpectedCall::MockCheckedExpectedCall()
: ignoreOtherParameters_(false), isActualCallMatchFinalized_(false),
initialExpectedCallOrder_(NO_EXPECTED_CALL_ORDER), finalExpectedCallOrder_(NO_EXPECTED_CALL_ORDER),
outOfOrder_(false), returnValue_(""), objectPtr_(NULL), wasPassedToObject_(true),
actualCalls_(0), minCalls_(1), maxCalls_(1)
{
inputParameters_ = new MockNamedValueList();
outputParameters_ = new MockNamedValueList();
}

MockCheckedExpectedCall::MockCheckedExpectedCall(unsigned int minCalls, unsigned int maxCalls)
: ignoreOtherParameters_(false), isActualCallMatchFinalized_(false),
initialExpectedCallOrder_(NO_EXPECTED_CALL_ORDER), finalExpectedCallOrder_(NO_EXPECTED_CALL_ORDER),
Expand Down
16 changes: 8 additions & 8 deletions tests/CppUTestExt/ExpectedFunctionsListTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ TEST_GROUP(MockExpectedCallsList)
void setup()
{
list = new MockExpectedCallsList;
call1 = new MockCheckedExpectedCall;
call2 = new MockCheckedExpectedCall;
call3 = new MockCheckedExpectedCall;
call4 = new MockCheckedExpectedCall;
call1 = new MockCheckedExpectedCall(1, 1);
call2 = new MockCheckedExpectedCall(1, 1);
call3 = new MockCheckedExpectedCall(1, 1);
call4 = new MockCheckedExpectedCall(1, 1);
call1->withName("foo");
call2->withName("bar");
call3->withName("boo");
Expand Down Expand Up @@ -85,8 +85,8 @@ TEST(MockExpectedCallsList, listWithFulfilledExpectationHasNoUnfulfilledOnes)

TEST(MockExpectedCallsList, listWithFulfilledExpectationButOutOfOrder)
{
call1->withCallOrder(1);
call2->withCallOrder(2);
call1->withCallOrder(1, 1);
call2->withCallOrder(2, 2);
list->addExpectedCall(call1);
list->addExpectedCall(call2);
call2->callWasMade(1);
Expand All @@ -107,8 +107,8 @@ TEST(MockExpectedCallsList, listWithUnFulfilledExpectationHasNoUnfillfilledOnes)

TEST(MockExpectedCallsList, deleteAllExpectationsAndClearList)
{
list->addExpectedCall(new MockCheckedExpectedCall);
list->addExpectedCall(new MockCheckedExpectedCall);
list->addExpectedCall(new MockCheckedExpectedCall(1, 1));
list->addExpectedCall(new MockCheckedExpectedCall(1, 1));
list->deleteAllExpectationsAndClearList();
}

Expand Down
6 changes: 3 additions & 3 deletions tests/CppUTestExt/MockActualCallTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST(MockCheckedActualCall, actualCallWithNoReturnValueAndMeaninglessCallOrderFo

TEST(MockCheckedActualCall, unExpectedParameterName)
{
MockCheckedExpectedCall call1;
MockCheckedExpectedCall call1(1, 1);
call1.withName("func");
list->addExpectedCall(&call1);

Expand All @@ -124,8 +124,8 @@ TEST(MockCheckedActualCall, unExpectedParameterName)

TEST(MockCheckedActualCall, multipleSameFunctionsExpectingAndHappenGradually)
{
MockCheckedExpectedCall* call1 = new MockCheckedExpectedCall();
MockCheckedExpectedCall* call2 = new MockCheckedExpectedCall();
MockCheckedExpectedCall* call1 = new MockCheckedExpectedCall(1, 1);
MockCheckedExpectedCall* call2 = new MockCheckedExpectedCall(1, 1);
call1->withName("func");
call2->withName("func");
list->addExpectedCall(call1);
Expand Down
9 changes: 4 additions & 5 deletions tests/CppUTestExt/MockExpectedCallTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ TEST_GROUP(MockExpectedCall)
MockCheckedExpectedCall* call;
void setup()
{
call = new MockCheckedExpectedCall;
call = new MockCheckedExpectedCall(1, 1);
}
void teardown()
{
Expand Down Expand Up @@ -570,7 +570,7 @@ TEST(MockExpectedCall, toStringForCallOrderSingle)
{
MockCheckedExpectedCall expectedCall(1, 1);
expectedCall.withName("name");
expectedCall.withCallOrder(2);
expectedCall.withCallOrder(2, 2);
expectedCall.callWasMade(1);
STRCMP_EQUAL("name -> expected call order: <2> -> no parameters (called 1 time)", expectedCall.callToString().asCharString());
}
Expand All @@ -591,7 +591,7 @@ TEST(MockExpectedCall, toStringForCallOrderMultiple)
TEST(MockExpectedCall, callOrderIsFulfilledButWithWrongOrderSingle)
{
call->withName("name");
call->withCallOrder(2);
call->withCallOrder(2, 2);
call->callWasMade(1);
CHECK(call->isFulfilled());
CHECK(call->isOutOfOrder());
Expand Down Expand Up @@ -624,7 +624,7 @@ TEST(MockExpectedCall, callOrderIsFulfilledButWithWrongOrderMultipleTooLate)
TEST(MockExpectedCall, callOrderIsFulfilledSingle)
{
call->withName("name");
call->withCallOrder(1);
call->withCallOrder(1, 1);
call->callWasMade(1);
CHECK(call->isFulfilled());
CHECK_FALSE(call->isOutOfOrder());
Expand Down Expand Up @@ -695,7 +695,6 @@ TEST_GROUP(MockIgnoredExpectedCall)
TEST(MockIgnoredExpectedCall, worksAsItShould)
{
ignored.withName("func");
ignored.withCallOrder(1);
ignored.withCallOrder(1, 1);
ignored.onObject((void*) 0);
ignored.withBoolParameter("umm", true);
Expand Down
4 changes: 2 additions & 2 deletions tests/CppUTestExt/MockFailureReporterForTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ MockExpectedCallsListForTest::~MockExpectedCallsListForTest()

MockCheckedExpectedCall* MockExpectedCallsListForTest::addFunction(const SimpleString& name)
{
MockCheckedExpectedCall* newCall = new MockCheckedExpectedCall;
MockCheckedExpectedCall* newCall = new MockCheckedExpectedCall(1, 1);
newCall->withName(name);
addExpectedCall(newCall);
return newCall;
Expand All @@ -115,6 +115,6 @@ MockCheckedExpectedCall* MockExpectedCallsListForTest::addFunction(unsigned int
MockCheckedExpectedCall* MockExpectedCallsListForTest::addFunction(const SimpleString& name, unsigned int order)
{
MockCheckedExpectedCall* newCall = addFunction(name);
newCall->withCallOrder(order);
newCall->withCallOrder(order, order);
return newCall;
}
6 changes: 3 additions & 3 deletions tests/CppUTestExt/MockFailureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ TEST_GROUP(MockFailureTest)
void setup ()
{
list = new MockExpectedCallsList;
call1 = new MockCheckedExpectedCall;
call2 = new MockCheckedExpectedCall;
call3 = new MockCheckedExpectedCall;
call1 = new MockCheckedExpectedCall(1, 1);
call2 = new MockCheckedExpectedCall(1, 1);
call3 = new MockCheckedExpectedCall(1, 1);
}
void teardown ()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CppUTestExt/MockStrictOrderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST(MockStrictOrderTest, OrderObserved)

TEST(MockStrictOrderTest, someOrderObserved)
{
mock().expectOneCall("foo3").withCallOrder(3);
mock().expectOneCall("foo3").withCallOrder(3, 3);
mock().expectOneCall("foo1");
mock().expectOneCall("foo2");
mock().actualCall("foo2");
Expand Down