UnitTest framework for C.
- 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.
int main(int argc, char* argv[]) {
return cutest_run_tests(argc, argv, stdout, NULL);
}
TEST(simple, test) {
ASSERT_NE_STR("hello", "world");
}
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.
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.
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.
Checkout Online manual for API reference.