xref: /freebsd/contrib/unifdef/tests/if7.c (revision 257e70f1d5ee61037c8c59b116538d3b6b1427a2)
1 /*
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 (FOOB | FOO) == 43
9 int foo1() { return 0; }
10 #else
11 #error FOOB bitwise-or FOO is not 43
12 #endif
13 
14 #if (FOO ^ FOO) == 0
15 int foo2() { return 0; }
16 #else
17 #error FOO bitwise-xor FOO is not 0
18 #endif
19 
20 #if (FOOB & 2) == 2
21 int foo3() { return 0; }
22 #else
23 #error FOOB bitwise-and 2 is not 2
24 #endif
25 
26 #if (FOO << 1) == 2
27 int foo4() { return 0; }
28 #else
29 #error FOO left-shift 2 is not 2
30 #endif
31 
32 #if (FOOB >> 4) == 2
33 int foo5() { return 0; }
34 #else
35 #error FOOB right-shift 2 is not 2
36 #endif
37 
38 #if (FOOB + FOO) == 43
39 int foo6() { return 0; }
40 #else
41 #error FOOB add FOO is not 43
42 #endif
43 
44 #if (FOOB - FOO) == 41
45 int foo7() { return 0; }
46 #else
47 #error FOOB subtract FOO is not 41
48 #endif
49 
50 #if (FOOB * 2) == 84
51 int foo8() { return 0; }
52 #else
53 #error FOOB multiply 2 is not 84
54 #endif
55 
56 #if (FOOB / 2) == 21
57 int foo9() { return 0; }
58 #else
59 #error FOOB divided 2 is not 21
60 #endif
61 
62 #if (FOOB % FOO) == 0
63 int foo10() { return 0; }
64 #else
65 #error FOOB modulo FOO is not 0
66 #endif
67 
68 #if ~(FOOB) == -43
69 int foo11() { return 0; }
70 #else
71 #error bitwise-not FOOB is not -43
72 #endif
73 
74 #if -(FOOB) == -42
75 int foo12() { return 0; }
76 #else
77 #error negate FOOB is not -42
78 #endif
79 
80 int main()
81 {
82   foo1();
83   foo2();
84   foo3();
85   foo4();
86   foo5();
87   foo6();
88   foo7();
89   foo8();
90   foo9();
91   foo10();
92   foo11();
93   foo12();
94 }
95