struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / scott-compare3.c
blob3f5e600a489c680890cbe30faf46a0e95bcb9fb9
1 /**
2 compare3.c
3 regression testing program for comparing literals to variables
4 */
5 #include <testfwk.h>
7 unsigned int aint0 = 0;
8 unsigned int aint1 = 0;
9 unsigned char achar0 = 0;
10 unsigned char achar1 = 0;
12 // compare to 0
13 // assumes
14 // achar0 == 0
15 // achar1 != 0
16 // aint0 == 0
17 // aint1 != 0
19 void c_0(void)
22 ASSERT(!(achar0 != 0));
24 ASSERT(!(achar0));
26 ASSERT(!(achar1 == 0));
28 ASSERT(!(!achar1));
30 ASSERT(!(aint0 != 0));
32 ASSERT(!(aint0));
34 ASSERT(!(aint1 == 0));
36 ASSERT(!(!aint1));
40 // compare to 1
41 // assumes
42 // achar0 != 1
43 // achar1 == 1
44 // aint0 != 1
45 // aint1 == 1
47 void c_1(void)
50 ASSERT(!(achar0 == 1));
52 ASSERT(!(achar1 != 1));
54 ASSERT(!(aint0 == 1));
56 ASSERT(!(aint1 != 1));
60 // compare to 2
61 // assumes
62 // achar0 == 2
63 // aint0 == 2
65 void c_2(void)
68 ASSERT(!(achar0 != 2));
70 ASSERT(!(aint0 != 2));
74 // compare to 0xff
75 // assumes
76 // achar0 == 0xff
77 // aint0 == 0xff
79 void c_ff(void)
82 ASSERT(!(achar0 != 0xff));
84 ASSERT(!(aint0 != 0xff));
86 ASSERT(!(aint0 == 0xfe));
88 ASSERT(!(aint0 == 0xff00U));
93 // compare to 0x00a5
94 // assumes
95 // achar0 == 0xa5
96 // aint0 == 0x00a5
98 void c_a5(void)
101 ASSERT(!(achar0 != 0xa5));
103 ASSERT(!(aint0 != 0xa5));
105 ASSERT(!(aint0 == 0xa4));
107 ASSERT(!(aint0 == 0xa500U));
111 // compare to 0xa500
112 // assumes
113 // achar0 == 0xa5
114 // aint0 == 0xa500
116 void c_a500(void)
119 ASSERT(!(achar0 == (unsigned char)0xa500U));
121 ASSERT(!(aint0 != 0xa500U));
123 ASSERT(!(aint0 == 0xa400U));
125 ASSERT(!(aint0 == 0x00a5));
129 // compare to 0xabcd
130 // assumes
131 // achar0 == 0xa5
132 // aint0 == 0xabcd
134 #ifndef __SDCC_pdk14 // Lack of memory
135 void c_abcd(void)
138 ASSERT(!(achar0 == (unsigned char)0xabcdU));
140 ASSERT(!(aint0 != 0xabcdU));
142 ASSERT(!(aint0 == 0xab00U));
144 ASSERT(!(aint0 == 0x00cd));
146 ASSERT(aint0 == (unsigned short int)0x1234abcdU);
149 #endif
151 void
152 testCompare3 (void)
154 #ifndef __SDCC_pdk14 // Lack of memory
155 aint1 = 1;
156 achar1 = 1;
157 c_0();
158 c_1();
160 aint0 = 2;
161 achar0 = 2;
162 c_2();
164 aint0 = 0xff;
165 achar0 = 0xff;
166 c_ff();
168 aint0 = 0xa5;
169 achar0 = 0xa5;
170 c_a5();
172 aint0 = 0xabcd;
173 c_abcd();
174 #endif