-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathtest.h
28 lines (23 loc) · 972 Bytes
/
test.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <stdint.h>
#include <time.h>
static inline int64_t wallclock(void)
{
struct timespec ts[1] = {{}};
clock_gettime(CLOCK_REALTIME, ts);
return (int64_t) ts->tv_sec * 1000000000ul + (int64_t) ts->tv_nsec;
}
#define FAIL(...) \
do { \
fprintf(stderr, "FAIL: "); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
abort(); \
} while (0)
#define REQUIRE(expr) \
do { \
if (!(expr)) \
FAIL("REQUIRE FAILED AT %s:%d WITH '%s'", __FUNCTION__, __LINE__, \
#expr); \
} while (0)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))