Imported Upstream version 2.9.0
[debian/cc1111] / src / regression / compare5.c
1 #include "gpsim_assert.h"
2 //
3 // compare5.c
4 // regression testing program for comparing longs
5 //
6
7 #define  COMPARE_OUT_OF_RANGE 1
8
9 unsigned char failures = 0;
10
11 int int0 = 0;
12 int int1 = 0;
13 char char0 = 0;
14 char char1 = 0;
15 long long0 = 0;
16 long long1 = 0;
17 unsigned long ulong0 = 0;
18 unsigned long ulong1 = 0;
19
20 void
21 done()
22 {
23   ASSERT(MANGLE(failures) == 0);
24   PASSED();
25 }
26
27 // compare to 0
28 // assumes
29 // long0 == 0
30 // ulong0 == 0
31
32 void c_0(void)
33 {
34
35   if(long0 != 0)
36     failures++;
37
38   if(long0 > 0)
39     failures++;
40
41   if(ulong0 != 0)
42     failures++;
43
44   if(ulong0 > 0)
45     failures++;
46
47 }
48
49 // compare to 1
50 // assumes
51 // long1 == 1
52 // ulong1 == 1
53
54 void c_1(void)
55 {
56
57   if(long0 == 1)
58     failures++;
59
60   if(long1 != 1)
61     failures++;
62
63   if(ulong0 == 1)
64     failures++;
65
66   if(ulong1 != 1)
67     failures++;
68
69   if(long1 < 0)
70     failures++;
71
72   if(long1 < 1)
73     failures++;
74
75   if(ulong1 < 1)
76     failures++;
77
78   if(long1 > 1)
79     failures++;
80
81   if(ulong1 > 1)
82     failures++;
83 }
84
85 // compare to 2
86 // assumes
87 // long0 == 2
88 // ulong0  == 2
89
90 void c_2(void)
91 {
92
93   if(long0 != 2)
94     failures++;
95
96   if(ulong0 != 2)
97     failures++;
98
99   if(long1 == 2)
100     failures++;
101
102   if(ulong1 == 2)
103     failures++;
104
105 }
106
107 // compare to 0xff
108 // assumes
109 // achar0 == 0xff
110 // aint0  == 0xff
111
112 void c_ff(void)
113 {
114
115   if(long0 != 0xff)
116     failures++;
117
118   if(ulong0 != 0xff)
119     failures++;
120
121   if(long1 == 0xff)
122     failures++;
123
124   if(ulong1 == 0xff)
125     failures++;
126
127
128 }
129
130 // compare to 0x200
131 // assumes
132 // achar0 == 0x200
133 // aint0  == 0x200
134
135 void c_200(void)
136 {
137
138   if(long0 != 0x200)
139     failures++;
140
141   if(ulong0 != 0x200)
142     failures++;
143
144   if(long1 == 0x200)
145     failures++;
146
147   if(ulong1 == 0x200)
148     failures++;
149
150
151 }
152
153 // compare to 0x20000
154 // assumes
155 // long0  == 0x20000
156 // ulong0 == 0x20000
157 // long1  != 0x20000
158 // ulong1 != 0x20000
159
160 void c_20000(void)
161 {
162
163   if(long0 != 0x20000)
164     failures++;
165
166   if(ulong0 != 0x20000)
167     failures++;
168
169   if(long1 == 0x20000)
170     failures++;
171
172   if(ulong1 == 0x20000)
173     failures++;
174
175   if(long0 <= 0x10000)
176     failures++;
177
178   if(long0 < 0x10000)
179     failures++;
180
181 /*  if(long0 < 0x12345)
182     failures++;
183 */
184   if(long0 == 0)
185     failures++;
186 }
187
188 // compare to 0x00a5
189 // assumes
190 // char0  == 0xa5
191 // int0  == 0x00a5
192
193 void c_a5(void)
194 {
195
196   if(char0 != 0xa5)
197     failures++;
198
199   if(int0 != 0xa5)
200     failures++;
201
202   if(int0 == 0xa4)
203     failures++;
204
205   if(int0 == 0xa500)
206     failures++;
207
208 }
209
210 // compare to 0xa500
211 // assumes
212 // char0  == 0xa5
213 // int0  == 0xa500
214
215 void c_a500(void)
216 {
217
218 #ifdef COMPARE_OUT_OF_RANGE
219   if(char0 == 0xa500)
220     failures++;
221 #endif
222
223   if(int0 != 0xa500)
224     failures++;
225
226   if(int0 == 0xa400)
227     failures++;
228
229   if(int0 == 0x00a5)
230     failures++;
231
232 }
233
234 // compare to 0xabcd
235 // assumes
236 // char0  == 0xa5
237 // int0  == 0xabcd
238
239 void c_abcd(void)
240 {
241 #ifdef COMPARE_OUT_OF_RANGE
242   if(char0 == 0xabcd)
243     failures++;
244 #endif
245
246   if(int0 != 0xabcd)
247     failures++;
248
249   if(int0 == 0xab00)
250     failures++;
251
252   if(int0 == 0x00cd)
253     failures++;
254
255   if(int0 == 0x05cd)
256     failures++;
257
258   if(int0 == 0xab05)
259     failures++;
260
261   if(int0 == 0xab01)
262     failures++;
263
264   if(int0 == 0x01cd)
265     failures++;
266
267   if(int0 > 0)
268     failures++;
269
270 #ifdef COMPARE_OUT_OF_RANGE
271   if(int0 == 0x1234abcd)
272     failures++;
273 #endif
274
275 }
276
277 // assumes char1 == 0
278 void c_ifelse1(void)
279 {
280
281   if(char0)
282     char0 = char1;
283   else
284     char0 = 0;
285
286   if(char0)
287     failures++;
288 }
289
290 // assumes char0 = -1
291 // assumes int0 = -1
292
293 void c_minus1(void)
294 {
295   if(long0 != -1)
296     failures++;
297
298   if(long0 > 0)
299     failures++;
300
301   if(long1 < 0)
302     failures++;
303 /*
304   if(long1 < 2)
305     failures++;
306 */
307 }
308
309 // assumes
310 // long0 = long1 = ulong0 = ulong1 == 0
311
312 void c_long2long_eq(void)
313 {
314
315   if(long0 != long1)
316     failures++;
317
318   if(ulong0 != ulong1)
319     failures++;
320
321   if(long0 != ulong1)
322     failures++;
323
324   if(long0 > long1)
325     failures++;
326
327   if(long0 < long1)
328     failures++;
329
330   if(long0 > ulong0)
331     failures++;
332
333   if(long0 < ulong0)
334     failures++;
335 }
336
337 // assumes
338 // long0 = ulong0 == 0
339 // long1 = ulong1 == 1
340
341 void c_long2long_neq(void)
342 {
343
344   if(long0 == long1)
345     failures++;
346
347   if(ulong0 == ulong1)
348     failures++;
349
350   if(long1 != ulong1)
351     failures++;
352
353   if(long1 < long0)
354     failures++;
355
356   if(long1 <= long0)
357     failures++;
358
359   if(ulong1 < ulong0)
360     failures++;
361
362   if(ulong1 <= ulong0)
363     failures++;
364
365 }
366
367
368 //  long0=-100;
369 //  long1=-1000;
370 void
371 c_long2neglit(void)
372 {
373
374   if(long0>0)
375     failures++;
376   if(long1>0)
377     failures++;
378
379   if(long1 > long0)
380     failures++;
381
382   if(long1 > 100)
383     failures++;
384
385   if(long0 > -50)
386     failures++;
387
388   if(long1 < -5000)
389     failures++;
390 }
391
392 void
393 main (void)
394 {
395
396   c_0();
397
398   c_long2long_eq();
399
400   long1 = 1;
401   ulong1 = 1;
402   c_1();
403   c_long2long_neq();
404
405   long0 = 2;
406   ulong0 = 2;
407   c_2();
408
409   long0 = 0xff;
410   ulong0 = 0xff;
411   c_ff();
412
413   long0 = 0x200;
414   ulong0 = 0x200;
415   c_200();
416
417   long0 = 0x20000;
418   ulong0 = 0x20000;
419   c_20000();
420
421   long0 = -1;
422   c_minus1();
423
424   long0=-100;
425   long1=-1000;
426   c_long2neglit();
427
428   done ();
429 }