xref: /freebsd/contrib/unifdef/tests/if5-k.c (revision aa1a8ff2d6dbc51ef058f46f3db5a8bb77967145)
1 /* Copyright 2004, 2008 Bob Proulx <bob@proulx.com>
2 Distributed under the two-clause BSD licence;
3 see the COPYING file for details. */
4 
5 #include <stdio.h>
6 #include <stdlib.h>
7 
8 #if 0
9 /* This code is commented out. "#if 0 then" */
10 #else
11 /* This code is passed through. "#if 0 else" */
12 #endif
13 
14 #if 1
15 /* This code is passed through. "#if 1 then" */
16 #else
17 /* This code is passed through. "#if 1 else" */
18 #endif
19 
20 #if FOOB == 42
21 int foo1() { return 0; }
22 #else
23 #error FOOB not 42
24 #endif
25 
26 #if FOOB != 42
27 #error FOO is 2
28 #else
29 int foo2() { return 0; }
30 #endif
31 
32 #if FOOB == 42 || FOO == 1
33 intx foo3() { return 0; }
34 #else
35 #error FOO not 1 or BAR not 1
36 #endif
37 
38 #if FOOB != 42 && FOO != 1
39 #error FOOB not 42 and FOO not 1
40 #else
41 int foo4() { return 0; }
42 #endif
43 
44 #if FOOB == 42 || FOO != 1
45 int foo5() { return 0; }
46 #else
47 #error FOOB is 42 or FOO is not 1
48 #endif
49 
50 #if FOO != 1 || FOOB != 42
51 #error FOO is 1 or FOOB is 42
52 #else
53 int foo6() { return 0; }
54 #endif
55 
56 int main()
57 {
58   foo1();
59   foo2();
60   foo3();
61   foo4();
62   foo5();
63   foo6();
64 }
65