Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20120427-2.c
blob7f2654c7d517c649e34a0e9415f70aa06dd8e975
1 /*
2 20120427-2.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c89
9 #endif
11 typedef struct sreal
13 unsigned sig; /* Significant. */
14 int exp; /* Exponent. */
15 } sreal;
17 int
18 sreal_compare (sreal *a, sreal *b)
20 if (a->exp > b->exp)
21 return 1;
22 if (a->exp < b->exp)
23 return -1;
24 if (a->sig > b->sig)
25 return 1;
26 if (a->sig < b->sig)
27 return -1;
28 return 0;
31 sreal a[] = {
32 { 0, 0 },
33 { 1, 0 },
34 { 0, 1 },
35 { 1, 1 }
38 void
39 testTortureExecute (void)
41 int i, j;
42 for (i = 0; i <= 3; i++) {
43 for (j = 0; j < 3; j++) {
44 ASSERT(!(i < j && sreal_compare(&a[i], &a[j]) != -1));
45 ASSERT(!(i == j && sreal_compare(&a[i], &a[j]) != 0));
46 ASSERT(!(i > j && sreal_compare(&a[i], &a[j]) != 1));