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-int-compare.c
blobbc05aee3e60d83eeeb3ea34e07f0cfce53d29762
1 /*
2 int-compare.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c89
9 #endif
11 #include <limits.h>
13 int gt (int a, int b)
15 return a > b;
18 int ge (int a, int b)
20 return a >= b;
23 int lt (int a, int b)
25 return a < b;
28 int le (int a, int b)
30 return a <= b;
33 void
34 true (int c)
36 if (!c)
37 ASSERT (0);
40 void
41 false (int c)
43 if (c)
44 ASSERT (0);
47 void f (void)
49 true (gt (2, 1));
50 false (gt (1, 2));
52 true (gt (INT_MAX, 0));
53 false (gt (0, INT_MAX));
54 true (gt (INT_MAX, 1));
55 false (gt (1, INT_MAX));
57 false (gt (INT_MIN, 0));
58 true (gt (0, INT_MIN));
59 false (gt (INT_MIN, 1));
60 true (gt (1, INT_MIN));
62 true (gt (INT_MAX, INT_MIN));
63 false (gt (INT_MIN, INT_MAX));
65 true (ge (2, 1));
66 false (ge (1, 2));
68 true (ge (INT_MAX, 0));
69 false (ge (0, INT_MAX));
70 true (ge (INT_MAX, 1));
71 false (ge (1, INT_MAX));
73 false (ge (INT_MIN, 0));
74 true (ge (0, INT_MIN));
75 false (ge (INT_MIN, 1));
76 true (ge (1, INT_MIN));
78 true (ge (INT_MAX, INT_MIN));
79 false (ge (INT_MIN, INT_MAX));
81 false (lt (2, 1));
82 true (lt (1, 2));
84 false (lt (INT_MAX, 0));
85 true (lt (0, INT_MAX));
86 false (lt (INT_MAX, 1));
87 true (lt (1, INT_MAX));
89 true (lt (INT_MIN, 0));
90 false (lt (0, INT_MIN));
91 true (lt (INT_MIN, 1));
92 false (lt (1, INT_MIN));
94 false (lt (INT_MAX, INT_MIN));
95 true (lt (INT_MIN, INT_MAX));
97 false (le (2, 1));
98 true (le (1, 2));
100 false (le (INT_MAX, 0));
101 true (le (0, INT_MAX));
102 false (le (INT_MAX, 1));
103 true (le (1, INT_MAX));
105 true (le (INT_MIN, 0));
106 false (le (0, INT_MIN));
107 true (le (INT_MIN, 1));
108 false (le (1, INT_MIN));
110 false (le (INT_MAX, INT_MIN));
111 true (le (INT_MIN, INT_MAX));
114 void
115 testTortureExecute (void)
117 f ();
118 return;