Skip to content

Latest commit

 

History

History
62 lines (42 loc) · 1.47 KB

README.md

File metadata and controls

62 lines (42 loc) · 1.47 KB

cutest

UnitTest framework for C.

Features

  1. Absolutely no memory allocation. You are safe to observe and measure your own program's memory usage.
  2. Tests are automatically registered when declared. No need to rewrite your test name!
  3. A rich set of assertions. And you can register your own type.
  4. Value-parameterized tests.

Quick start

Step 1. Call entrypoint function in your main()

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.