-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpp_test.c
More file actions
45 lines (35 loc) · 1.43 KB
/
pp_test.c
File metadata and controls
45 lines (35 loc) · 1.43 KB
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
#include "pp.h"
#include <assert.h>
#include <stdio.h>
int main(int argc, char** argv)
{
assert(0 == PP_BOOL(0) && "Unexpected boolean value");
assert(1 == PP_BOOL(1) && "Unexpected boolean value");
assert(1 == PP_BOOL(10) && "Unexpected boolean value");
assert(5 == PP_ADD(3, 2) && "Unexpected arithmetic value");
assert(6 == PP_MUL(3, 2) && "Unexpected arithmetic value");
assert(1 == PP_SUB(3, 2) && "Unexpected arithmetic value");
assert(2 == PP_DIV(4, 2) && "Unexpected arithmetic value");
assert(10 == PP_MUL(PP_ADD(2, 3), 2) && "Unexpected arithmetic value");
assert(1 == PP_BOOL(PP_ADD(2, 3)) && "Unexpected boolean value");
// assert(0 == PP_LEN() && "Unexpected len");
assert(1 == PP_LEN(1) && "Unexpected len");
assert(2 == PP_LEN(1, 1) && "Unexpected len");
assert(3 == PP_LEN(1, 1, 1) && "Unexpected len");
assert('f' == PP_IF(0, 't', 'f') && "Unexpected if result");
assert('t' == PP_IF(1, 't', 'f') && "Unexpected if result");
assert('t' == PP_IF(2, 't', 'f') && "Unexpected if result");
assert(0 == PP_GET_NTH(0, 0, 1, 2, 3));
assert(1 == PP_GET_NTH(1, 0, 1, 2, 3));
assert(2 == PP_GET_NTH(2, 0, 1, 2, 3));
assert(3 == PP_GET_NTH(3, 0, 1, 2, 3));
do {
#define INC_X(it) ++x;
int x = 0;
PP_FOR(0, 10, INC_X);
assert(x == 10);
#undef INC_X
} while(0);
printf("passed\n");
return 0;
}