STest is simple unit tests for C/C++.
- The code uses only the standard C99 This allows you to use the STest in the oldest projects with older compilers.
- The code has no dependencies, and imprisoned in the one file.
- Support simple (single) tests.
- Support case(s) of tests.
- Support
init
andclean
functions for test in case. - Support three levels (
PASS
,SKIP
,FAIL
) - Support macro
ASSERT
andSTATIC_ASSERT
- Support macro
stest_printf
- for select print function in embeded system - Support color in console (optional) see stest.h
- You need to include stest.h file in your .c/.cpp file.
- Use the macro
TEST(name)
to write test. - Use the macros
TEST_PASS(msg)
,TEST_SKIP(msg)
,TEST_FAIL(msg)
for exit from test. - Or use the macros
TEST_ASSERT(expr)
,TEST_ASSERT2(expr, msg)
- Use the macro
MAIN_*
for declare functionmain
, or directly use therun_case(s)
function in embeded system. - Compile and run test.
Note: STest uses the standard clib
printf
function from stdio.h. If you are using STest on an embedded system perhaps you have your own function or less resource-intensive one like xprintf Then uncomment the definitionstest_ptintf
and add your function. The function must have signature likeprintf
and must support printing for formats: %s %d %u
Copyright (C) 2017 Koynov Stas - skojnov@yandex.ru