# Unit tests for C

## 1. About

The `sigscheme/test-c/` directory is existing for unit testing for C. The tests are currently using our own testing framework. See test-c/README for further information.

## 2. Requirements for testing framework

I had tried to use the famous CUnit at first to test SigScheme, but it did not met my requirements and needs long way to modify to fit to SigScheme. So I searched for other testing frameworks and once decided to modify Cutter. Please let me know better solutions if you know.

- Written in pure C

  - To avoid C++-specific interferences especially stacks, frames and exceptions with GC

  - To allow running tests on platforms that has poor or no C++ support

- Don't terminate a test even if an assertion is failed

- Prints the expected and actual values when an assertion failed, as follows

    ./test_format.c:64: - format ~D -
    expected: <0>
     but was: <2147483647>

- Standalone test runner

      i.e. There is no need to write the main function for each test.

- Automatic testsuite configuration

      i.e. There is no need to register all tests into a testsuite by hand.

- It can be inserted SCM_GC_PROTECTED_CALL() on each tests

And some recommendations:

- Small and Simple

- Assertions macro names are short

- Assertions have assert(expected, actual) form instead of assert(actual, expected)