[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unit_test_teardown


On Friday 25 October 2013 21:08:02 Jan Paesmans wrote:
> Hi,

Hey,

> I'm trying to create a unit test with no setup and a teardown function.
> Like in the code below:
> 
> static void teardown_testing(void **state)
> {
>         free(*state);
> }
> 
> static void testing(void **state)
> {
>         *state = malloc(1);
>         assert_non_null(*state);
> }
> 
> int main(int argc, char *argv[])
> {
>         (void)argc;
>         (void)argv;
> 
>         const UnitTest tests[] = {
>                 unit_test_teardown(testing, teardown_testing),
>         };
> 
>         return run_tests(tests);
> }
> 
> This code fails to compile, however this is the way I exepected cmocka
> to work. Please correct me if I'm wrong.
> However I think the problem is with the definition of the
> unit_test_teardown macro.
> Examining the macro shows that unit_test_teardown(test, teardown) is
> expanded to:
> _unit_test_setup(test, setup), \
> unit_test(test), \
> _unit_test_teardown(test, teardown)
> 
> However, there is no setup in the unit_test_teardown macro arguments,
> causing gcc to give an error about missing setup.

this is probably a copy and paste error :) I've fixed it. It will be in the 
next bugfix release.


Thanks for reporting!


	-- andreas



-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx


Follow-Ups:
Re: unit_test_teardownJan Paesmans <jan.paesmans@xxxxxxxxx>
References:
unit_test_teardownJan Paesmans <jan.paesmans@xxxxxxxxx>