Skip to content

Commit 3999548

Browse files
committed
Added C language new call for setMaxCallLogSize.
1 parent fb5653f commit 3999548

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

include/CppUTestExt/MockSupport_c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ struct SMockSupport_c
195195
void (*disable)(void);
196196
void (*enable)(void);
197197
void (*ignoreOtherCalls)(void);
198+
void (*setMaxCallLogSize)(unsigned int maxSize);
198199

199200
void (*checkExpectations)(void);
200201
int (*expectedCallsLeft)(void);

src/CppUTestExt/MockSupport_c.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ MockActualCall_c* actualCall_c(const char* name);
131131
void disable_c();
132132
void enable_c();
133133
void ignoreOtherCalls_c();
134+
void setMaxCallLogSize_c(unsigned int maxSize);
134135
void setBoolData_c(const char* name, int value);
135136
void setIntData_c(const char* name, int value);
136137
void setUnsignedIntData_c(const char* name, unsigned int value);
@@ -351,6 +352,7 @@ static MockSupport_c gMockSupport = {
351352
disable_c,
352353
enable_c,
353354
ignoreOtherCalls_c,
355+
setMaxCallLogSize_c,
354356
checkExpectations_c,
355357
expectedCallsLeft_c,
356358
clear_c,
@@ -862,6 +864,11 @@ void ignoreOtherCalls_c()
862864
currentMockSupport->ignoreOtherCalls();
863865
}
864866

867+
void setMaxCallLogSize_c(unsigned int maxSize)
868+
{
869+
currentMockSupport->setMaxCallLogSize(maxSize);
870+
}
871+
865872
void setBoolData_c(const char* name, int value)
866873
{
867874
currentMockSupport->setData(name, (value != 0));

tests/CppUTestExt/MockSupport_cTest.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,3 +696,23 @@ TEST(MockSupport_c, ignoreOtherCalls)
696696
mock_c()->actualCall("bar");
697697
mock_c()->checkExpectations();
698698
}
699+
700+
static void failingUnexpectedCallWithActualCallLogLimited_()
701+
{
702+
mock_c()->setMaxCallLogSize(2);
703+
mock_c()->expectAnyCalls("foo");
704+
mock_c()->actualCall("foo");
705+
mock_c()->actualCall("foo");
706+
mock_c()->actualCall("foo");
707+
mock_c()->actualCall("bar");
708+
} // LCOV_EXCL_LINE
709+
710+
TEST(MockSupport_c, setMaxCallLogSize)
711+
{
712+
TestTestingFixture fixture;
713+
fixture.runTestWithMethod(failingUnexpectedCallWithActualCallLogLimited_);
714+
fixture.assertPrintContains("ACTUAL calls that were expected (in call order):\n"
715+
"\t\t(2) foo -> no parameters\n"
716+
"\t\t(3) foo -> no parameters");
717+
}
718+

0 commit comments

Comments
 (0)