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
initandcleanfunctions for test in case. - Support three levels (
PASS,SKIP,FAIL) - Support macro
ASSERTandSTATIC_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
printffunction 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_ptintfand add your function. The function must have signature likeprintfand must support printing for formats: %s %d %u
Copyright (C) 2017 Koynov Stas - [email protected]