-
Notifications
You must be signed in to change notification settings - Fork 2
/
Test.h
56 lines (42 loc) · 1.17 KB
/
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
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
55
56
/* Test.h */
/* Lightweight TAP (Test Anything Protocol) emitter in C macros. */
/* Example usage:
#include <string.h>
#include "../Test.h"
int
main(int argc, char * argv[])
{
char s[7];
plan(1);
ok(1==1, "1 is equal to 1");
is_ii(1+1, 2, "1 plus 1 is equal to 2");
strcpy(s, "foo"); strcat(s, "bar");
is_ss(s, "foobar", "strcpy and strcat");
return 0;
}
*/
#include <stdio.h> /* printf */
int _test_number=0; /* yes, namespace pollution. patches welcome ;-) */
#define plan(count) printf("1..%d\n", count)
#define \
ok(flag,desc) \
printf("%sok %d - %s\n", \
flag?"":"not ",++_test_number,desc)
#define \
is_ii(got,expected,desc) \
printf("%sok %d - %s\n", \
got==expected?"":"not ",++_test_number,desc); \
if(got!=expected) \
printf("# got : %d\n# expected : %d\n", got, expected)
#define \
is_ss(got,expected,desc) \
printf("%sok %d - %s\n", \
strcmp(got,expected)?"not ":"",++_test_number,desc)
#define \
isnt_pp(got,expected,desc) \
printf("%sok %d - %s\n", \
(got!=expected)?"":"not ", ++_test_number, desc)
#define \
diag(message) \
printf("# %s\n", message)
/* end of Test.h */