Added more samples
This commit is contained in:
parent
7b5cad2e2c
commit
1442807e1f
4 changed files with 42 additions and 32 deletions
|
@ -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
24
samples/report.c
Normal 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");
|
||||
}
|
|
@ -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
9
samples/suites.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(first_suite, test) {
|
||||
assert(1);
|
||||
}
|
||||
|
||||
Test(second_suite, test) {
|
||||
assert(1);
|
||||
}
|
Loading…
Add table
Reference in a new issue