aboutsummaryrefslogtreecommitdiff
path: root/unit/include/bh/unit.h
blob: f245d03e3313081f64e7b6aa1d3a9dac02f9d83f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef BH_UNIT_H
#define BH_UNIT_H

#include <stdio.h>

typedef int (*bh_unit_cb_t)(void);

#define bh_unit_assert(e)                                                    \
    if (!(e)) {                                                              \
        printf("%s:%d\t%s\n", __FILE__, __LINE__, #e);                       \
        return -1;                                                           \
    }


#define bh_unit_assert_delta(x, y, e)                                        \
    if ((((x)>(y))?((x)-(y)):((y)-(x)))>(e)) {                               \
        printf("%s:%d\t%s\n", __FILE__, __LINE__, #x " == " #y);             \
        return -1;                                                           \
    }

void bh_unit_add(const char *name, bh_unit_cb_t func);
int bh_unit_run(void);

#endif /* BH_UNIT_H */