Home

Awesome

CT

(Relatively) Easy Unit Testing for C

How to use

  1. Copy subdirectory ct into your project.
  2. Add some rules to your makefile. See Makefile for an example.
  3. Write some tests. See msg-test.c for an example. Test function names begin with "cttest".
  4. Run make check

Behavior

Terminal Output

Running make -j4 check in the example supplied looks like this:

$ make -j4 check
cc -Werror -Wall -Wformat=2   -c -o msg-test.o msg-test.c
cc -Werror -Wall -Wformat=2   -c -o ct/ct.o ct/ct.c
cc -Werror -Wall -Wformat=2   -c -o msg.o msg.c
ct/gen msg-test.o > ct/_ctcheck.c.part
mv ct/_ctcheck.c.part ct/_ctcheck.c
cc -Werror -Wall -Wformat=2   -c -o ct/_ctcheck.o ct/_ctcheck.c
cc   ct/_ctcheck.o ct/ct.o msg.o msg-test.o   -o ct/_ctcheck
ct/_ctcheck
.......

PASS

Remove some of the return statements in msg-test.c to see what various errors and failures look like.

Releases

There will be no releases of this tool. Just clone the latest source from git and copy it into your project. If you want to update, copy the newer source into your project.

History

Inspired by CUT 2.1 by Sam Falvo and Billy Tanksley. Also with ideas from the Go testing package and gotest. Also stole some benchmark hints from testingbee by Dustin Sallings.