1. About

The sigscheme/test-c/ directory is existing for unit testing for C. The tests are currently using privately-customized version of Cutter testing framework. Although it is a quick-hacked product, sufficiently works for SigScheme.

The private patch can be used and redistributed under the original license of Cutter.

2. How to use

  1. Check out Cutter revision 20

    svn co -r20 http://www.cozmixng.org/repos/c/cutter/trunk cutter
  2. Apply the private patch for SigScheme

  3. Install pached version of Cutter

  4. Build and run tests

    $ make all test

3. How to write new test

  1. Copy the template

    $ cp test_template.c test_foo.c
    The filename must be test_*.c
  2. Add following lines into Makefile.am and re-configure

    TEST_SRCS               += test_foo.c
    noinst_LTLIBRARIES      += libtest_foo.la
    libtest_foo_la_SOURCES  = test_foo.c cutter-sscm.h
    libtest_foo_la_LIBADD   = $(top_builddir)/src/libsscm.la
  3. Write your own tests into test_foo.c likewise test_template.c

    UT_DEF2("my test")
    {
        UT_ASSERT_EQUAL_XINT(0, ~0);
    }
    UT_REGISTER_BEGIN("my testsuite")
    UT_REGISTER_END
    See cutter/assersions.h to find appropriate assertion macros.
  4. Configure testsuite

    $ make update-suites
    This makes test_foo.c as follows:
    UT_DEF2(test_1, "my test")
    {
        UT_ASSERT_EQUAL_XINT(0, ~0);
    }
    UT_REGISTER_BEGIN("my testsuite")
    UT_REGISTER(test_1, "my test")
    UT_REGISTER_END
    There is no need to remove the auto-generated fragments on re-update.
  5. Build and run tests

    $ make all test

4. 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 decided to modify Cutter. Please let me know better solutions if you know.

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

And some recommendations: