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