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

void exit(int);
struct FILE;
typedef struct FILE FILE;
int fprintf(FILE*, const char*, ...);
extern FILE* stderr;
int strcmp(const char*, const char*);

#define ASSERT(a, file, line) \
    do { \
        if (!(a)) { \
            fprintf(stderr, "%s:%d: assert failed\n", file, line); \
            exit(1); \
        } \
    } while (0)

#define ASSERT_EQ(a, b) ASSERT((a) == (b), __FILE__, __LINE__)
#define ASSERT_EQ_STR(a, b) ASSERT(strcmp((a), (b)) == 0, __FILE__, __LINE__)

#endif