aboutsummaryrefslogtreecommitdiff
path: root/testing.h
blob: 0b479c95e2b64ff64004848b0f5c5d32d8cf5d5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13

#include <stdio.h>

#define t_assert(fact)                                                         \
  if (!(fact)) {                                                               \
    fprintf(stderr, "Assertion failed: %s at %s:%d in %s()\n",  #fact, __FILE__, __LINE__, __func__); \
    return 1;                                                                  \
  }

  # define t_assert_equal(a, b) \
  if (!(a == b)) { \
    fprintf(stderr, "Assertion failed: %d (%s) != %d (%s) at %s:%d in %s()\n", a, #a, b, #b, __FILE__, __LINE__, __func__); \
    return 1; \
  }