As part of the function validation, it is also possible to validate the parameters passed from the unit.
void test_addition(void) {
EXPECT ( invalid );
EXPECT ( invalid );
EXPECT_VALIDATE ( add, check_add );
VALIDATE(calculate(3,7,'+'), EXPECTED_SUM);
}
The EXPECT_VALIDATE macro shown in sample6 above2.1, instructs the framework
to expect a function call to add. check_add
is a reference to a mock that will verify the arguments being passed
to add. This mock function must have the same prototype as the
function it validates. The sample function check_add
shown below has the same prototype as the function add
called by calculate.
int check_add(int left_operand, int right_operand) {
VALIDATE(left_operand,3);
VALIDATE(right_operand,7);
return 10;
}
The function validates that each of the parameters are as expected for this test.
Other tests might have other expectations to the parameters, so they will use another
mock function. It is possible to have many mock functions, each of which
can be used to test parameters for add in different scenarios.
The output from the mock function check_add will look something like this
PASSED verify left_operand expected .......... 3 (3) actual ............ 3 PASSED right_operand expected .......... 7 (7) actual ............ 7
New is this release are support for floating point validations and function mocking. Also, MinGW has been added to the list of supported platforms.
moreTestApe forum is now hosted on Proboards. Support questions can be posted here or send directly on email. Due to ...
moreTestApe can now be used with MinGW GCC on windows. Also supported in this beta are floating point types in validations or when mocking functions
moreA small fix for webtty scripts, to allow the usage from Apple IPads. Tab on textarea to bring up IPad keyboard - you may have to scroll webpage beneath keyboard, in order to actually see what you're typing.
This release contains a new flexible mocking system with default mocks automatically generated for unresolved functions. Installation packages are available for GCC/Linux, GCC/CygWin as well Visual Studio 2009/Windows XP or Vista.
moreNew beta version is now available for download. This is the last beta before official release. The release supports an extensive mocking system.
moreThere is a change for the forum hosted on this site. The previous phpBB forum is closed for now. All forum threads will be migrated to a new simple blog. ...
more