CeDOS - tests/tap.h

tests/tap.h (view raw)

#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