tests/tap.h (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#ifndef INCLUDE_TAP_H
#define INCLUDE_TAP_H
#include <stdbool.h>
#include <stdio.h>
#include <cedos.h>
static int test_id;
static inline void plan(const char *test_name, int num_tests) {
printf("## STARTING TEST %s\n", test_name);
printf("1..%i\n", num_tests);
test_id = 1;
}
static inline void test_true(bool value, const char *comment) {
if (value) {
printf("ok %i", test_id++);
} else {
printf("not ok %i", test_id++);
}
if (comment != NULL) {
printf(" # %s\n", comment);
} else {
printf("\n");
}
}
static inline void test_zero(int value, const char *comment) {
test_true(value == 0, comment);
}
static inline void test_nonzero(int value, const char *comment) {
test_true(value != 0, comment);
}
#endif