Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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
Loading
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 C language new calls for multi-matching expected calls.
  • Loading branch information
jgonzalezdr committed Jun 28, 2016
commit 8ee564aab45a024a2e24dba991947b2f29ad2c2d
8 changes: 7 additions & 1 deletion 8 include/CppUTestExt/MockSupport_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ struct SMockSupport_c
void (*strictOrder)(void);
MockExpectedCall_c* (*expectOneCall)(const char* name);
void (*expectNoCall)(const char* name);
MockExpectedCall_c* (*expectNCalls)(int number, const char* name);
MockExpectedCall_c* (*expectNCalls)(unsigned int number, const char* name);
MockExpectedCall_c* (*expectAtLeastOneCall)(const char* name);
MockExpectedCall_c* (*expectAtLeastNCalls)(unsigned int amount, const char* name);
MockExpectedCall_c* (*expectAtMostOneCall)(const char* name);
MockExpectedCall_c* (*expectAtMostNCalls)(unsigned int amount, const char* name);
MockExpectedCall_c* (*expectAnyCalls)(const char* name);
MockExpectedCall_c* (*expectRangeOfCalls)(unsigned int minCalls, unsigned int maxCalls, const char* name);
MockActualCall_c* (*actualCall)(const char* name);
int (*hasReturnValue)(void);
MockValue_c (*returnValue)(void);
Expand Down
52 changes: 50 additions & 2 deletions 52 src/CppUTestExt/MockSupport_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ extern "C" {
void strictOrder_c();
MockExpectedCall_c* expectOneCall_c(const char* name);
void expectNoCall_c(const char* name);
MockExpectedCall_c* expectNCalls_c(const int number, const char* name);
MockExpectedCall_c* expectNCalls_c(const unsigned int number, const char* name);
MockExpectedCall_c* expectAtLeastOneCall_c(const char* name);
MockExpectedCall_c* expectAtLeastNCalls_c(const unsigned int number, const char* name);
MockExpectedCall_c* expectAtMostOneCall_c(const char* name);
MockExpectedCall_c* expectAtMostNCalls_c(const unsigned int number, const char* name);
MockExpectedCall_c* expectAnyCalls_c(const char* name);
MockExpectedCall_c* expectRangeOfCalls_c(const unsigned int minCalls, const unsigned int maxCalls, const char* name);
MockActualCall_c* actualCall_c(const char* name);
void disable_c();
void enable_c();
Expand Down Expand Up @@ -303,6 +309,12 @@ static MockSupport_c gMockSupport = {
expectOneCall_c,
expectNoCall_c,
expectNCalls_c,
expectAtLeastOneCall_c,
expectAtLeastNCalls_c,
expectAtMostOneCall_c,
expectAtMostNCalls_c,
expectAnyCalls_c,
expectRangeOfCalls_c,
actualCall_c,
hasReturnValue_c,
returnValue_c,
Expand Down Expand Up @@ -568,12 +580,48 @@ void expectNoCall_c(const char* name)
currentMockSupport->expectNoCall(name);
}

MockExpectedCall_c* expectNCalls_c(const int number, const char* name)
MockExpectedCall_c* expectNCalls_c(const unsigned int number, const char* name)
{
expectedCall = &currentMockSupport->expectNCalls(number, name);
return &gExpectedCall;
}

MockExpectedCall_c* expectAtLeastOneCall_c(const char* name)
{
expectedCall = &currentMockSupport->expectAtLeastOneCall(name);
return &gExpectedCall;
}

MockExpectedCall_c* expectAtLeastNCalls_c(const unsigned int number, const char* name)
{
expectedCall = &currentMockSupport->expectAtLeastNCalls(number, name);
return &gExpectedCall;
}

MockExpectedCall_c* expectAtMostOneCall_c(const char* name)
{
expectedCall = &currentMockSupport->expectAtMostOneCall(name);
return &gExpectedCall;
}

MockExpectedCall_c* expectAtMostNCalls_c(const unsigned int number, const char* name)
{
expectedCall = &currentMockSupport->expectAtMostNCalls(number, name);
return &gExpectedCall;
}

MockExpectedCall_c* expectAnyCalls_c(const char* name)
{
expectedCall = &currentMockSupport->expectAnyCalls(name);
return &gExpectedCall;
}

MockExpectedCall_c* expectRangeOfCalls_c(const unsigned int minCalls, const unsigned int maxCalls, const char* name)
{
expectedCall = &currentMockSupport->expectRangeOfCalls(minCalls, maxCalls, name);
return &gExpectedCall;
}

MockActualCall_c* actualCall_c(const char* name)
{
actualCall = &currentMockSupport->actualCall(name);
Expand Down
46 changes: 46 additions & 0 deletions 46 tests/CppUTestExt/MockSupport_cTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,52 @@ TEST(MockSupport_c, expectNoCall)
mock_c()->checkExpectations();
}

TEST(MockSupport_c, expectAtLeastOneCallFulfilled)
{
mock_c()->expectAtLeastOneCall("boo");
mock_c()->actualCall("boo");
mock_c()->checkExpectations();
}

TEST(MockSupport_c, expectAtLeastNCallsFulfilled)
{
mock_c()->expectAtLeastNCalls(2, "boo");
mock_c()->actualCall("boo");
mock_c()->actualCall("boo");
mock_c()->checkExpectations();
}

TEST(MockSupport_c, expectAtMostOneCallFulfilled)
{
mock_c()->expectAtMostOneCall("boo");
mock_c()->checkExpectations();
}

TEST(MockSupport_c, expectAtMostNCallsFulfilled)
{
mock_c()->expectAtMostNCalls(4, "boo");
mock_c()->actualCall("boo");
mock_c()->actualCall("boo");
mock_c()->actualCall("boo");
mock_c()->actualCall("boo");
mock_c()->checkExpectations();
}

TEST(MockSupport_c, expectAnyCallsFulfilled)
{
mock_c()->expectAnyCalls("boo");
mock_c()->checkExpectations();
}

TEST(MockSupport_c, expectRangeOfCallsFulfilled)
{
mock_c()->expectRangeOfCalls(2, 4, "boo");
mock_c()->actualCall("boo");
mock_c()->actualCall("boo");
mock_c()->actualCall("boo");
mock_c()->checkExpectations();
}

TEST(MockSupport_c, expectAndActualParameters)
{
mock_c()->expectOneCall("boo")->withIntParameters("integer", 1)->withDoubleParameters("double", 1.0)->
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.