Added more samples

This commit is contained in:
Snaipe 2015-02-06 13:10:08 +01:00
parent 7b5cad2e2c
commit 1442807e1f
4 changed files with 42 additions and 32 deletions

View file

@ -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

24
samples/report.c Normal file
View file

@ -0,0 +1,24 @@
#include <stdio.h>
#include <criterion/criterion.h>
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");
}

View file

@ -1,37 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <criterion/criterion.h>
#include <criterion/assert.h>
#include <criterion/hooks.h>
#include <criterion/stats.h>
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);
}

9
samples/suites.c Normal file
View file

@ -0,0 +1,9 @@
#include <criterion/criterion.h>
Test(first_suite, test) {
assert(1);
}
Test(second_suite, test) {
assert(1);
}