cutest
UnitTest framework for C.
Features
- Absolutely no memory allocation. You are safe to observe and measure your own program's memory usage.
- Tests are automatically registered when declared. No need to rewrite your test name!
- A rich set of assertions. And you can register your own type.
- Value-parameterized tests.
Quick start
main()
Step 1. Call entrypoint function in your int main(int argc, char* argv[]) {
return cutest_run_tests(argc, argv, stdout, NULL);
}
Step 2. Write your test code
TEST(simple, test) {
ASSERT_NE_STR("hello", "world");
}
Step 3. Nothing more!
You are done for everything! Compile your code and run, you will have following output:
[==========] total 1 test registered.
[ RUN ] simple.test
[ OK ] simple.test (0 ms)
[==========] 1/1 test case ran. (0 ms total)
[ PASSED ] 1 test.
Integration
CMake
Add following code to your CMakeLists.txt:
add_subdirectory(cutest)
target_link_libraries(${YOUR_TEST_EXECUTABLE} PRIVATE cutest)
Remember to replace ${YOUR_TEST_EXECUTABLE}
with your actual executable name.
Manually
Just copy cutest.h
(in include/
directory) and cutest.c
(in src/
directory) to your build tree, and you are done.
Please do note that cutest.c
use #include "cutest.h"
syntax to find the header file, so be sure it can be found.
Documents
Checkout Online manual for API reference.