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
Added functionality to MockSupport to limit the maximum size of the a…
…ctual calls log.

The actual calls log limit is inherited hierarchically between mock scopes.
  • Loading branch information
jgonzalezdr committed Jul 5, 2016
commit fb5653fbfe4c7c5c290fa1f40d1c2cddd238d670
1 change: 1 addition & 0 deletions include/CppUTestExt/MockSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class MockSupport
virtual void enable();
virtual void tracing(bool enabled);
virtual void ignoreOtherCalls();
virtual void setMaxCallLogSize(unsigned int maxSize);

virtual void checkExpectations();
virtual bool expectedCallsLeft();
Expand Down
13 changes: 13 additions & 0 deletions src/CppUTestExt/MockSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ void MockSupport::clear()

expectations_.deleteAllExpectationsAndClearList();
actualCalls_.clear();
actualCalls_.setMaxSize((unsigned int) -1);
ignoreOtherCalls_ = false;
enabled_ = true;
actualCallOrder_ = 0;
Expand Down Expand Up @@ -288,6 +289,17 @@ void MockSupport::tracing(bool enabled)
if (getMockSupport(p)) getMockSupport(p)->tracing(enabled);
}

void MockSupport::setMaxCallLogSize(unsigned int maxSize)
{
actualCalls_.setMaxSize(maxSize);

for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) {
if (getMockSupport(p)) {
getMockSupport(p)->setMaxCallLogSize(maxSize);
}
}
}

const char* MockSupport::getTraceOutput()
{
return MockActualCallTrace::instance().getTraceOutput();
Expand Down Expand Up @@ -523,6 +535,7 @@ MockSupport* MockSupport::clone(const SimpleString& mockName)
if (strictOrdering_) newMock->strictOrder();

newMock->tracing(tracing_);
newMock->setMaxCallLogSize(actualCalls_.getMaxSize());
newMock->installComparatorsAndCopiers(comparatorsAndCopiersRepository_);
return newMock;
}
Expand Down
30 changes: 30 additions & 0 deletions tests/CppUTestExt/MockSupportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ TEST(MockSupportTest, tracing)
STRCMP_CONTAINS("foo", mock().getTraceOutput());
}

TEST(MockSupportTest, setMaxCallLogSize)
{
mock().setMaxCallLogSize(2);
mock("foo").setMaxCallLogSize(3);

mock().expectAnyCalls("boo");
mock("foo").expectAnyCalls("baa");
mock("bar").expectAnyCalls("buu");

mock().actualCall("boo");
mock().actualCall("boo");
mock().actualCall("boo");
mock("foo").actualCall("baa");
mock("foo").actualCall("baa");
mock("foo").actualCall("baa");
mock("foo").actualCall("baa");
mock("foo").actualCall("baa");
mock("foo").actualCall("baa");
mock("foo").actualCall("baa");
mock("bar").actualCall("buu");
mock("bar").actualCall("buu");
mock("bar").actualCall("buu");
mock("bar").actualCall("buu");
mock("bar").actualCall("buu");

LONGS_EQUAL(2, mock().getActualCalls().size())
LONGS_EQUAL(3, mock("foo").getActualCalls().size())
LONGS_EQUAL(2, mock("bar").getActualCalls().size())
}

TEST(MockSupportTest, tracingWorksHierarchically)
{
mock("scope").tracing(true);
Expand Down