summaryrefslogtreecommitdiff
path: root/tests/test.h
blob: 1d60ca8c10e55955d0d9f5be555f0e9cb21d8024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef TEST_H
#define TEST_H

#include <stdio.h>

#define TEST_CASE(__case_name__, __case__) int __case_name__(){ \
  const char* testname = #__case_name__;\
  int fail_counter = 0;\
  __case__\
  return fail_counter;\
}

#define CHECK(__assertion__) {\
  total_assertions += 1; \
  if (!(__assertion__)) {\
  printf("Test failed: %s in %s:%d\n> " #__assertion__ "\n", testname, __FILE__, __LINE__);\
  fail_counter += 1;\
}}

extern int total_assertions;

#endif