note
lima1
Yeah, but it is also quite easy to implement a [cpan://Test::More] like testsuite in C with libtab ([http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap]). This library is pretty small, so you can ship it with your program. I just added a 't' directory in my autoconf based project and put the libtab header and sources there. Tests look pretty much the same as in Perl:
<code>
# t/simple_tests.c
#include <stdio.h>
#include "tap.h"
#include "something.h"
int
main(void)
{
plan_tests(1);
/*
* A simple example of a test.
*/
ok(1 + 1 == 2, "Basic arithmetic works");
return exit_status(); /* Return the correct exit code */
}
</code>
A simple t/Makefile.am could look like this:
<code>
# binaries
check_PROGRAMS = simple_tests
simple_tests_SOURCES = simple_tests.c tap.c ../src/something.c\
tap.h ../src/something.h
simple_tests_CFLAGS = -Wall --pedantic -std=c99 -I ../src
TESTS = simple_tests
</code>
Then add 't' in your main Makefile.am:
<code>
SUBDIRS = src t
</code>
Then you can run the tests with 'make check'.
641503
641507