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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef TESTS_COMMON_H
#define TESTS_COMMON_H
#include "iemnet.h"
#include <stdlib.h>
static inline void pass(void) {exit(0); }
static inline void fail(void) {exit(1); }
static inline void skip(void) {exit(77); }
#include <stdio.h>
#include <stdarg.h>
static inline void pass_if (int test, int line, const char *format, ...)
{
if (test) {
va_list argptr ;
printf("@%d: ", line);
va_start (argptr, format) ;
vprintf (format, argptr) ;
va_end (argptr) ;
printf("\n");
pass();
} ;
} /* pass_if */
static inline void skip_if (int test, int line, const char *format, ...)
{
if (test) {
va_list argptr ;
printf("@%d: ", line);
va_start (argptr, format) ;
vprintf (format, argptr) ;
va_end (argptr) ;
printf("\n");
skip();
} ;
} /* skip_if */
static inline void fail_if (int test, int line, const char *format, ...)
{
if (test) {
va_list argptr ;
printf("@%d: ", line);
va_start (argptr, format) ;
vprintf (format, argptr) ;
va_end (argptr) ;
printf("\n");
fail();
} ;
} /* fail_if */
#define STRINGIFY(x) #x
#define STARTTEST(x) printf("============ %s[%04d]:\t%s '%s'\n", __FILE__, __LINE__, __FUNCTION__, x)
#endif /* TESTS_COMMON_H */
|