1 /** Compare with 2^n greater then 255
2 test for patch #2702889 - Summary of all uncommitted changes I applied on "my" SDCC
7 foreach(`int_right', (0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000), `
9 lwr_if_`'int_right (unsigned left)
18 lwr_`'int_right (unsigned left)
20 return left < int_right;
24 test_lwr_`'int_right (void)
26 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
27 ASSERT (lwr_if_`'int_right (int_right - 1));
28 ASSERT (!lwr_if_`'int_right (int_right));
29 ASSERT (!lwr_if_`'int_right (int_right + 1));
31 ASSERT (lwr_`'int_right (int_right - 1));
32 ASSERT (!lwr_`'int_right (int_right));
33 ASSERT (!lwr_`'int_right (int_right + 1));
38 foreach(`int_right', (0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff), `
39 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
41 gtr_if_`'int_right (unsigned left)
43 return (left > int_right) ? 1 : 0;
47 gtr_`'int_right (unsigned left)
49 return left > int_right;
54 test_gtr_`'int_right (void)
56 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
57 ASSERT (gtr_if_`'int_right (int_right + 1));
58 ASSERT (!gtr_if_`'int_right (int_right));
59 ASSERT (!gtr_if_`'int_right (int_right - 1));
61 ASSERT (gtr_`'int_right (int_right + 1));
62 ASSERT (!gtr_`'int_right (int_right));
63 ASSERT (!gtr_`'int_right (int_right - 1));
68 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
69 /* special case for 0x0000 */
71 lwr_if_0x0000 (unsigned left)
80 lwr_0x0000 (unsigned left)
87 test_lwr_0x0000 (void)
89 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
90 ASSERT (!lwr_if_0x0000 (0x0000 - 1));
91 ASSERT (!lwr_if_0x0000 (0x0000));
92 ASSERT (!lwr_if_0x0000 (0x0000 + 1));
94 ASSERT (!lwr_0x0000 (0x0000 - 1));
95 ASSERT (!lwr_0x0000 (0x0000));
96 ASSERT (!lwr_0x0000 (0x0000 + 1));
100 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
101 #if !defined(PORT_HOST)
102 /* special case for 0xffff */
104 gtr_if_0xffff (unsigned left)
106 return (left > 0xffff) ? 1 : 0;
110 gtr_0xffff (unsigned left)
112 return left > 0xffff;
118 test_gtr_0xffff (void)
120 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
121 #if !defined(PORT_HOST)
122 ASSERT (!gtr_if_0xffff (0xffff + 1));
123 ASSERT (!gtr_if_0xffff (0xffff));
124 ASSERT (!gtr_if_0xffff (0xffff - 1));
126 ASSERT (!gtr_0xffff (0xffff + 1));
127 ASSERT (!gtr_0xffff (0xffff));
128 ASSERT (!gtr_0xffff (0xffff - 1));
133 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
134 /* unsigned long test cases */
135 #define LONG_RIGHT_LWR 0x80000000
137 long_lwr (unsigned long left)
139 return (left < LONG_RIGHT_LWR) ? 1 : 0;
142 #define LONG_RIGHT_GTR 0x7fffffff
144 long_gtr (unsigned long left)
146 if (left > LONG_RIGHT_GTR)
156 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
157 ASSERT (long_lwr (LONG_RIGHT_LWR - 1));
158 ASSERT (!long_lwr (LONG_RIGHT_LWR));
159 ASSERT (!long_lwr (LONG_RIGHT_LWR + 1));
161 ASSERT (long_gtr (LONG_RIGHT_GTR + 1));
162 ASSERT (!long_gtr (LONG_RIGHT_GTR));
163 ASSERT (!long_gtr (LONG_RIGHT_GTR - 1));
167 /* Test for bug #2165 Broken comparison */
171 bug_2165 (unsigned i)
176 {c = i < 0x0100; return 0;}
180 test_bug_bug_2165 (void)
182 ASSERT (bug_2165 (254));
183 ASSERT (bug_2165 (255));
184 ASSERT (!bug_2165 (256));