Menu

#20 Have CU_ASSERT_FATAL style macros which allow test cleanup

open
nobody
None
1
2014-05-14
2014-05-14
Anonymous
No

It would be useful to have a CU_ASSERT_FATAL(_XXX) set of macros which allow a unit test to clean up after itself.

In my code I added a CU_ASSERT_END macro, which, on failure, jumps to the CU_END label (which a unit test function must define) in order to allow a unit test to perform test-specific clean-up (eg, memory deallocation).

This naive implementation only aborts the current function; not the entire call-chain as the _FATAL macros do, but this is sufficient for my current simplistic unit tests.

define CU_ASSERT_END(_TEST) do { \

int _testresult; \
CU_ASSERT( _testresult = (_TEST) ); \
if(!_testresult) { goto CU_END; } \
} while(0)

Thoughts?

Discussion

Anonymous
Anonymous

Add attachments
Cancel