From f8bba4b3a519147de59a2a7c3dc6262549e7e2bb Mon Sep 17 00:00:00 2001 From: Joseph Ates Date: Wed, 10 Feb 2016 12:16:13 +0100 Subject: cmocka: Add will_return_maybe() for ignoring mock returns As both parameter and function call order checking allow for ignoring cases where they are never invoked, the mock return values are at somewhat of a mismatch in that they must always be returned at least once (even in the case of will_return_always()). Therefore, the ability to set the count to -2 on will_return_count was added with a new macro (will_return_maybe) that indicates that that the value field may never be returned and still allow a successful test. Reviewed-by: Andreas Schneider --- tests/CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/CMakeLists.txt') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4b015ba..0422487 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,7 +19,9 @@ set(CMOCKA_TESTS test_skip test_setup_fail test_ordering - test_ordering_fail) + test_ordering_fail + test_returns + test_returns_fail) foreach(_CMOCKA_TEST ${CMOCKA_TESTS}) add_cmocka_test(${_CMOCKA_TEST} ${_CMOCKA_TEST}.c ${CMOCKA_STATIC_LIBRARY}) @@ -33,7 +35,7 @@ add_cmocka_test(test_cmockery test_cmockery.c ${CMOCKA_STATIC_LIBRARY}) ### Exceptions -# test_assert_macros_fail +# test_skip set_tests_properties( test_skip PROPERTIES @@ -57,6 +59,14 @@ set_tests_properties( "\\[ FAILED \\] 7 test" ) +# test_returns_fail ensure proper failures +set_tests_properties( + test_returns_fail + PROPERTIES + PASS_REGULAR_EXPRESSION + "\\[ FAILED \\] 3 test" +) + # test_exception_handler if (WIN32) set_tests_properties( -- cgit v1.2.3