diff --git a/samples/Makefile.am b/samples/Makefile.am index 4fa4cac..84ffec3 100644 --- a/samples/Makefile.am +++ b/samples/Makefile.am @@ -1,7 +1,12 @@ -TESTS = signal simple +TESTS = \ + signal \ + report \ + suites \ + simple + TESTS_ENVIRONMENT = CRITERION_ALWAYS_SUCCEED=1 -check_PROGRAMS = signal simple +check_PROGRAMS = $(TESTS) CFLAGS = -I$(top_srcdir)/include/ LDADD = -L$(top_srcdir)/ -lcriterion diff --git a/samples/report.c b/samples/report.c new file mode 100644 index 0000000..e806322 --- /dev/null +++ b/samples/report.c @@ -0,0 +1,24 @@ +#include +#include + +Test(sample, test) { + expect(0); + assert(1); +} + +ReportHook(PRE_INIT)(struct criterion_test *test) { + printf("testing %s in category %s\n", test->name, test->category); +} + +ReportHook(POST_TEST)(struct criterion_test_stats *stats) { + printf("Asserts: [%d passed, %d failed, %d total]\n", + stats->passed_asserts, stats->failed_asserts, stats->passed_asserts + stats->failed_asserts); +} + +ReportHook(PRE_EVERYTHING)() { + puts("criterion_init"); +} + +ReportHook(POST_EVERYTHING)() { + puts("criterion_fini"); +} diff --git a/samples/simple.c b/samples/simple.c index cd07611..c9dfa27 100644 --- a/samples/simple.c +++ b/samples/simple.c @@ -1,37 +1,9 @@ -#include -#include #include -#include -#include -#include Test(misc, failing) { - assert(1); assert(0); } -Test(misc, simple) { - expect(1); -} - -Test(abcd, crash) { - int *i = NULL; - *i = 42; -} - -ReportHook(PRE_INIT)(struct criterion_test *test) { - printf("testing %s in category %s\n", test->name, test->category); -} - -ReportHook(POST_TEST)(struct criterion_test_stats *stats) { - printf("Asserts: [%d passed, %d failed, %d total]\n", - stats->passed_asserts, stats->failed_asserts, stats->passed_asserts + stats->failed_asserts); -} - -ReportHook(PRE_EVERYTHING)() { - puts("criterion_init"); -} - -ReportHook(POST_EVERYTHING)() { - puts("criterion_fini"); +Test(misc, passing) { + assert(1); } diff --git a/samples/suites.c b/samples/suites.c new file mode 100644 index 0000000..50edf6e --- /dev/null +++ b/samples/suites.c @@ -0,0 +1,9 @@ +#include + +Test(first_suite, test) { + assert(1); +} + +Test(second_suite, test) { + assert(1); +}