diff options
Diffstat (limited to 'all_pairs/source/ammunition/ammunition.c')
-rw-r--r-- | all_pairs/source/ammunition/ammunition.c | 1185 |
1 files changed, 1185 insertions, 0 deletions
diff --git a/all_pairs/source/ammunition/ammunition.c b/all_pairs/source/ammunition/ammunition.c new file mode 100644 index 0000000..224babd --- /dev/null +++ b/all_pairs/source/ammunition/ammunition.c | |||
@@ -0,0 +1,1185 @@ | |||
1 | /* | ||
2 | |||
3 | This program is part of the TACLeBench benchmark suite. | ||
4 | Version V 2.0 | ||
5 | |||
6 | Name: ammunition | ||
7 | |||
8 | Author: Vladimir Makarov <vmakarov@gcc.gnu.org> | ||
9 | |||
10 | Function: Tests reusable packages bits and arith | ||
11 | bits: Work with bit strings (copying, moving, setting, testing, comparison). | ||
12 | arith: Implementing host machine-independently arbitrary precision integer | ||
13 | numbers arithmetic. The implementation of the package functions are not | ||
14 | sufficiently efficient in order to use for run-time. The package | ||
15 | functions are oriented to implement constant-folding in compilers, | ||
16 | cross-compilers. | ||
17 | |||
18 | Source: DINO programming language repository | ||
19 | https://github.com/dino-lang/dino/ | ||
20 | |||
21 | Changes: no major functional changes | ||
22 | |||
23 | License: GPL 2 and LGPL 2 | ||
24 | |||
25 | */ | ||
26 | |||
27 | #include "../extra.h" | ||
28 | #include "bits.h" | ||
29 | #include "arithm.h" | ||
30 | #include "ammunition_stdlib.h" | ||
31 | #include "ammunition_stdio.h" | ||
32 | #include "ammunition_string.h" | ||
33 | |||
34 | /* | ||
35 | Forward declaration of functions | ||
36 | */ | ||
37 | |||
38 | void ammunition_reset_str_bits( char *str, char *s ); | ||
39 | void ammunition_reset_str_arithm( char *str, char *s, char *d, char *e, | ||
40 | char *g ); | ||
41 | int ammunition_bits_test(); | ||
42 | int ammunition_arithm_test(); | ||
43 | void ammunition_init( void ); | ||
44 | int ammunition_return( void ); | ||
45 | void ammunition_main( void ); | ||
46 | //int main( void ); | ||
47 | |||
48 | |||
49 | /* | ||
50 | Forward declaration of global variables | ||
51 | */ | ||
52 | |||
53 | int ammunition_result; | ||
54 | |||
55 | |||
56 | /* | ||
57 | Core functions | ||
58 | */ | ||
59 | |||
60 | void ammunition_reset_str_bits( char *str, char *s ) | ||
61 | { | ||
62 | int i; | ||
63 | _Pragma( "loopbound min 8 max 8" ) | ||
64 | for ( i = 0; i < 8; i++ ) { | ||
65 | str[i] = 0; | ||
66 | s[i] = 0; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | |||
71 | void ammunition_reset_str_arithm( char *str, char *s, char *d, char *e, | ||
72 | char *g ) | ||
73 | { | ||
74 | int i; | ||
75 | _Pragma( "loopbound min 20 max 20" ) | ||
76 | for ( i = 0; i < 20; i++ ) { | ||
77 | str[i] = 0; | ||
78 | s[i] = 0; | ||
79 | } | ||
80 | |||
81 | _Pragma( "loopbound min 4 max 4" ) | ||
82 | for ( i = 0; i < 4; i++ ) { | ||
83 | d[i] = 0; | ||
84 | e[i] = 0; | ||
85 | } | ||
86 | |||
87 | _Pragma( "loopbound min 6 max 6" ) | ||
88 | for ( i = 0; i < 6; i++ ) | ||
89 | g[i] = 0; | ||
90 | } | ||
91 | |||
92 | |||
93 | int ammunition_bits_test() | ||
94 | { | ||
95 | char str[8]; | ||
96 | char str1[8]; | ||
97 | |||
98 | int result = 0; | ||
99 | unsigned int i, j; | ||
100 | |||
101 | /* Test 1 */ | ||
102 | ammunition_reset_str_bits( str, str1 ); | ||
103 | |||
104 | _Pragma( "loopbound min 64 max 64" ) | ||
105 | for ( i = 0; i < sizeof ( str ) * CHAR_BIT; i++ ) { | ||
106 | if ( BIT ( str, i ) ) | ||
107 | result = 1; | ||
108 | } | ||
109 | |||
110 | _Pragma( "loopbound min 64 max 64" ) | ||
111 | for ( i = 0; i < sizeof ( str ) * CHAR_BIT; i++ ) { | ||
112 | SET_BIT ( str, i, 1 ); | ||
113 | _Pragma( "loopbound min 64 max 64" ) | ||
114 | for ( j = 0; j < sizeof ( str ) * CHAR_BIT; j++ ) | ||
115 | if ( j <= i ) { | ||
116 | if ( BIT ( str, j ) == 0 ) | ||
117 | result = 1; | ||
118 | } else | ||
119 | if ( BIT ( str, j ) ) | ||
120 | result = 1; | ||
121 | } | ||
122 | |||
123 | /* Test 2 */ | ||
124 | ammunition_reset_str_bits( str, str1 ); | ||
125 | |||
126 | _Pragma( "loopbound min 64 max 64" ) | ||
127 | for ( i = 0; i < sizeof ( str ) * CHAR_BIT; i++ ) | ||
128 | if ( !ammunition_is_zero_bit_string ( | ||
129 | str, i, ( sizeof ( str ) * CHAR_BIT - i ) / 2 + 1 ) ) | ||
130 | result = 1; | ||
131 | ammunition_bit_string_set ( str, 13, 1, 35 ); | ||
132 | _Pragma( "loopbound min 13 max 13" ) | ||
133 | for ( i = 0; i < 13; i++ ) | ||
134 | if ( !ammunition_is_zero_bit_string ( str, i, 13 - i ) ) | ||
135 | result = 1; | ||
136 | _Pragma( "loopbound min 35 max 35" ) | ||
137 | for ( i = 13; i < 48; i++ ) | ||
138 | if ( ammunition_is_zero_bit_string ( str, i, 48 - i ) ) | ||
139 | result = 1; | ||
140 | _Pragma( "loopbound min 16 max 16" ) | ||
141 | for ( i = 48; i < sizeof ( str ) * CHAR_BIT; i++ ) | ||
142 | if ( !ammunition_is_zero_bit_string ( str, i, | ||
143 | sizeof ( str ) * CHAR_BIT - i ) ) | ||
144 | result = 1; | ||
145 | |||
146 | /* Test 3 */ | ||
147 | ammunition_reset_str_bits( str, str1 ); | ||
148 | |||
149 | _Pragma( "loopbound min 42 max 42" ) | ||
150 | for ( i = 0; i + i / 2 + 1 < sizeof ( str ) * CHAR_BIT; i++ ) { | ||
151 | ammunition_bit_string_set ( str, i, 1, i / 2 + 1 ); | ||
152 | if ( !ammunition_is_zero_bit_string ( str, 0, i - 1 ) ) | ||
153 | result = 1; | ||
154 | if ( ammunition_is_zero_bit_string ( str, i, i / 2 + 1 ) ) | ||
155 | result = 1; | ||
156 | if ( !ammunition_is_zero_bit_string ( | ||
157 | str, i + i / 2 + 1, sizeof ( str ) * CHAR_BIT - ( i + i / 2 + 1 ) ) ) | ||
158 | result = 1; | ||
159 | ammunition_bit_string_set ( str, 0, 0, sizeof ( str ) * CHAR_BIT ); | ||
160 | } | ||
161 | |||
162 | /* Test 4 */ | ||
163 | ammunition_reset_str_bits( str, str1 ); | ||
164 | |||
165 | ammunition_bit_string_set ( str, 2, 1, 43 ); | ||
166 | ammunition_bit_string_set ( str1, 2, 1, 40 ); | ||
167 | _Pragma( "loopbound min 42 max 42" ) | ||
168 | for ( i = 0; i < 42; i++ ) | ||
169 | if ( ammunition_bit_string_comparison ( str, i, str1, i, 42 - i ) != 0 ) | ||
170 | result = 1; | ||
171 | _Pragma( "loopbound min 43 max 43" ) | ||
172 | for ( i = 0; i < 43; i++ ) | ||
173 | if ( ammunition_bit_string_comparison ( str, i, str1, i, | ||
174 | sizeof ( str ) * CHAR_BIT - i ) | ||
175 | <= 0 ) | ||
176 | result = 1; | ||
177 | _Pragma( "loopbound min 43 max 43" ) | ||
178 | for ( i = 0; i < 43; i++ ) | ||
179 | if ( ammunition_bit_string_comparison ( str1, i, str, i, | ||
180 | sizeof ( str ) * CHAR_BIT - i ) | ||
181 | >= 0 ) | ||
182 | result = 1; | ||
183 | |||
184 | /* Test 5 */ | ||
185 | ammunition_reset_str_bits( str, str1 ); | ||
186 | |||
187 | ammunition_bit_string_set ( str, 2, 1, 43 ); | ||
188 | _Pragma( "loopbound min 59 max 59" ) | ||
189 | for ( i = 0; i + 5 < sizeof ( str ) * CHAR_BIT; i++ ) { | ||
190 | ammunition_bit_string_copy ( str1, i + 5, str, i, | ||
191 | sizeof ( str ) * CHAR_BIT - i - 5 ); | ||
192 | if ( ammunition_bit_string_comparison ( | ||
193 | str1, i + 5, str, i, sizeof ( str ) * CHAR_BIT - i - 5 ) != 0 ) | ||
194 | result = 1; | ||
195 | } | ||
196 | |||
197 | /* Test 6 */ | ||
198 | ammunition_reset_str_bits( str, str1 ); | ||
199 | |||
200 | ammunition_bit_string_set ( str, 2, 1, 43 ); | ||
201 | ammunition_bit_string_set ( str1, 2, 1, 43 ); | ||
202 | _Pragma( "loopbound min 59 max 59" ) | ||
203 | for ( i = 0; i + 5 < sizeof ( str ) * CHAR_BIT; i++ ) { | ||
204 | ammunition_bit_string_set ( str, 0, 0, sizeof ( str ) * CHAR_BIT ); | ||
205 | ammunition_bit_string_set ( str, 2, 1, 43 ); | ||
206 | ammunition_bit_string_move ( str, i + 5, str, i, | ||
207 | sizeof ( str ) * CHAR_BIT - i - 5 ); | ||
208 | if ( ammunition_bit_string_comparison ( | ||
209 | str, i + 5, str1, i, sizeof ( str ) * CHAR_BIT - i - 5 ) != 0 ) | ||
210 | result = 1; | ||
211 | } | ||
212 | |||
213 | /* Test 7 */ | ||
214 | ammunition_reset_str_bits( str, str1 ); | ||
215 | |||
216 | ammunition_bit_string_set ( str, 2, 1, 43 ); | ||
217 | ammunition_bit_string_set ( str1, 2, 1, 43 ); | ||
218 | _Pragma( "loopbound min 59 max 59" ) | ||
219 | for ( i = 0; i + 5 < sizeof ( str ) * CHAR_BIT; i++ ) { | ||
220 | ammunition_bit_string_set ( str, 0, 0, sizeof ( str ) * CHAR_BIT ); | ||
221 | ammunition_bit_string_set ( str, 2, 1, 43 ); | ||
222 | ammunition_bit_string_move ( str, i, str, i + 5, | ||
223 | sizeof ( str ) * CHAR_BIT - i - 5 ); | ||
224 | if ( ammunition_bit_string_comparison ( | ||
225 | str, i, str1, i + 5, sizeof ( str ) * CHAR_BIT - i - 5 ) != 0 ) | ||
226 | result = 1; | ||
227 | } | ||
228 | |||
229 | return result; | ||
230 | } | ||
231 | |||
232 | |||
233 | int ammunition_arithm_test() | ||
234 | { | ||
235 | int result = 0; | ||
236 | |||
237 | /* Test 1 */ | ||
238 | int i; | ||
239 | char str [20], s[20], d[4], e[4], g[6]; | ||
240 | |||
241 | ammunition_integer_from_string ( 4, "-2147483649", d ); | ||
242 | if ( !ammunition_overflow_bit ) | ||
243 | result = 1; | ||
244 | ammunition_sprintf_d( str, INT_MIN ); | ||
245 | ammunition_integer_from_string ( 4, str, d ); | ||
246 | if ( ammunition_overflow_bit ) | ||
247 | result = 1; | ||
248 | ammunition_integer_to_string( 4, d, s ); | ||
249 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
250 | result = 1; | ||
251 | ammunition_integer_from_string ( 4, "2147483648", d ); | ||
252 | if ( !ammunition_overflow_bit ) | ||
253 | result = 1; | ||
254 | ammunition_sprintf_d( str, INT_MAX ); | ||
255 | ammunition_integer_from_string ( 4, str, d ); | ||
256 | if ( ammunition_overflow_bit ) | ||
257 | result = 1; | ||
258 | ammunition_integer_to_string( 4, d, s ); | ||
259 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
260 | result = 1; | ||
261 | _Pragma( "loopbound min 4000 max 4000" ) | ||
262 | for ( i = -2000; i < 2000 ; i++ ) { | ||
263 | ammunition_sprintf_d( str, i ); | ||
264 | ammunition_integer_from_string ( 4, str, d ); | ||
265 | if ( ammunition_overflow_bit ) | ||
266 | result = 1; | ||
267 | ammunition_integer_to_string( 4, d, s ); | ||
268 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
269 | result = 1; | ||
270 | } | ||
271 | |||
272 | /* Test 2 */ | ||
273 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
274 | |||
275 | ammunition_unsigned_integer_from_string ( 4, "4294967296", d ); | ||
276 | if ( !ammunition_overflow_bit ) | ||
277 | result = 1; | ||
278 | ammunition_sprintf_u( str, UINT_MAX ); | ||
279 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
280 | if ( ammunition_overflow_bit ) | ||
281 | result = 1; | ||
282 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
283 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
284 | result = 1; | ||
285 | _Pragma( "loopbound min 4000 max 4000" ) | ||
286 | for ( i = 0; i < 4000 ; i++ ) { | ||
287 | ammunition_sprintf_u( str, i ); | ||
288 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
289 | if ( ammunition_overflow_bit ) | ||
290 | result = 1; | ||
291 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
292 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
293 | result = 1; | ||
294 | } | ||
295 | |||
296 | /* Test 3 */ | ||
297 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
298 | |||
299 | ammunition_sprintf_d( str, INT_MAX ); | ||
300 | ammunition_integer_from_string ( 4, str, d ); | ||
301 | ammunition_integer_from_string ( 4, "1", e ); | ||
302 | ammunition_add_integer ( 4, d, e, d ); | ||
303 | if ( !ammunition_overflow_bit ) | ||
304 | result = 1; | ||
305 | ammunition_sprintf_d( str, INT_MAX - 4 ); | ||
306 | ammunition_integer_from_string ( 4, str, d ); | ||
307 | ammunition_sprintf_d( str, 4 ); | ||
308 | ammunition_integer_from_string ( 4, str, e ); | ||
309 | ammunition_add_integer ( 4, d, e, d ); | ||
310 | if ( ammunition_overflow_bit ) | ||
311 | result = 1; | ||
312 | ammunition_integer_to_string( 4, d, s ); | ||
313 | ammunition_sprintf_d( str, INT_MAX ); | ||
314 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
315 | result = 1; | ||
316 | _Pragma( "loopbound min 4000 max 4000" ) | ||
317 | for ( i = -2000; i < 2000 ; i++ ) { | ||
318 | ammunition_sprintf_d( str, i ); | ||
319 | ammunition_integer_from_string ( 4, str, d ); | ||
320 | ammunition_sprintf_d( str, i + 1 ); | ||
321 | ammunition_integer_from_string ( 4, str, e ); | ||
322 | ammunition_add_integer ( 4, d, e, d ); | ||
323 | if ( ammunition_overflow_bit ) | ||
324 | result = 1; | ||
325 | ammunition_integer_to_string( 4, d, s ); | ||
326 | if ( ammunition_atoi ( s ) != i + i + 1 ) | ||
327 | result = 1; | ||
328 | } | ||
329 | |||
330 | /* Test 4 */ | ||
331 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
332 | |||
333 | ammunition_sprintf_u( str, UINT_MAX ); | ||
334 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
335 | ammunition_unsigned_integer_from_string ( 4, "1", e ); | ||
336 | ammunition_add_unsigned_integer ( 4, d, e, d ); | ||
337 | if ( !ammunition_overflow_bit ) | ||
338 | result = 1; | ||
339 | ammunition_sprintf_u( str, UINT_MAX - 4 ); | ||
340 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
341 | ammunition_sprintf_u( str, 4 ); | ||
342 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
343 | ammunition_add_unsigned_integer ( 4, d, e, d ); | ||
344 | if ( ammunition_overflow_bit ) | ||
345 | result = 1; | ||
346 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
347 | ammunition_sprintf_u( str, UINT_MAX ); | ||
348 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
349 | result = 1; | ||
350 | _Pragma( "loopbound min 4000 max 4000" ) | ||
351 | for ( i = 0; i < 4000 ; i++ ) { | ||
352 | ammunition_sprintf_u( str, i ); | ||
353 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
354 | ammunition_sprintf_u( str, i + 1 ); | ||
355 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
356 | ammunition_add_unsigned_integer ( 4, d, e, d ); | ||
357 | if ( ammunition_overflow_bit ) | ||
358 | result = 1; | ||
359 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
360 | if ( ammunition_atoi ( s ) != i + i + 1 ) | ||
361 | result = 1; | ||
362 | } | ||
363 | |||
364 | /* Test 5 */ | ||
365 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
366 | |||
367 | ammunition_sprintf_d( str, INT_MIN ); | ||
368 | ammunition_integer_from_string ( 4, str, d ); | ||
369 | ammunition_integer_from_string ( 4, "1", e ); | ||
370 | ammunition_subtract_integer ( 4, d, e, d ); | ||
371 | if ( !ammunition_overflow_bit ) | ||
372 | result = 1; | ||
373 | ammunition_sprintf_d( str, INT_MIN + 4 ); | ||
374 | ammunition_integer_from_string ( 4, str, d ); | ||
375 | ammunition_sprintf_d( str, 4 ); | ||
376 | ammunition_integer_from_string ( 4, str, e ); | ||
377 | ammunition_subtract_integer ( 4, d, e, d ); | ||
378 | if ( ammunition_overflow_bit ) | ||
379 | result = 1; | ||
380 | ammunition_integer_to_string( 4, d, s ); | ||
381 | ammunition_sprintf_d( str, INT_MIN ); | ||
382 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
383 | result = 1; | ||
384 | _Pragma( "loopbound min 4000 max 4000" ) | ||
385 | for ( i = -2000; i < 2000 ; i++ ) { | ||
386 | ammunition_sprintf_d( str, i ); | ||
387 | ammunition_integer_from_string ( 4, str, d ); | ||
388 | ammunition_sprintf_d( str, 10 - i ); | ||
389 | ammunition_integer_from_string ( 4, str, e ); | ||
390 | ammunition_subtract_integer ( 4, d, e, d ); | ||
391 | if ( ammunition_overflow_bit ) | ||
392 | result = 1; | ||
393 | ammunition_integer_to_string( 4, d, s ); | ||
394 | if ( ammunition_atoi ( s ) != i + i - 10 ) | ||
395 | result = 1; | ||
396 | } | ||
397 | |||
398 | /* Test 6 */ | ||
399 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
400 | |||
401 | ammunition_sprintf_u( str, UINT_MAX - 2 ); | ||
402 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
403 | ammunition_sprintf_u( str, UINT_MAX - 1 ); | ||
404 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
405 | ammunition_subtract_unsigned_integer ( 4, d, e, d ); | ||
406 | if ( !ammunition_overflow_bit ) | ||
407 | result = 1; | ||
408 | ammunition_sprintf_u( str, UINT_MAX ); | ||
409 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
410 | ammunition_subtract_unsigned_integer ( 4, d, d, d ); | ||
411 | if ( ammunition_overflow_bit ) | ||
412 | result = 1; | ||
413 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
414 | if ( ammunition_strcmp ( s, "0" ) != 0 ) | ||
415 | result = 1; | ||
416 | _Pragma( "loopbound min 4000 max 4000" ) | ||
417 | for ( i = 0; i < 4000 ; i++ ) { | ||
418 | ammunition_sprintf_u( str, i ); | ||
419 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
420 | ammunition_sprintf_u( str, i / 2 ); | ||
421 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
422 | ammunition_subtract_unsigned_integer ( 4, d, e, d ); | ||
423 | if ( ammunition_overflow_bit ) | ||
424 | result = 1; | ||
425 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
426 | if ( ammunition_atoi ( s ) != i - i / 2 ) | ||
427 | result = 1; | ||
428 | } | ||
429 | |||
430 | /* Test 7 */ | ||
431 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
432 | |||
433 | ammunition_sprintf_d( str, INT_MAX / 2 + 1 ); | ||
434 | ammunition_integer_from_string ( 4, str, d ); | ||
435 | ammunition_integer_from_string ( 4, "2", e ); | ||
436 | ammunition_multiply_integer ( 4, d, e, d ); | ||
437 | if ( !ammunition_overflow_bit ) | ||
438 | result = 1; | ||
439 | ammunition_sprintf_d( str, INT_MIN / 2 - 1 ); | ||
440 | ammunition_integer_from_string ( 4, str, d ); | ||
441 | ammunition_integer_from_string ( 4, "2", e ); | ||
442 | ammunition_multiply_integer ( 4, d, e, d ); | ||
443 | if ( !ammunition_overflow_bit ) | ||
444 | result = 1; | ||
445 | ammunition_sprintf_d( str, INT_MAX / 3 ); | ||
446 | ammunition_integer_from_string ( 4, str, d ); | ||
447 | ammunition_sprintf_d( str, 3 ); | ||
448 | ammunition_integer_from_string ( 4, str, e ); | ||
449 | ammunition_multiply_integer ( 4, d, e, d ); | ||
450 | if ( ammunition_overflow_bit ) | ||
451 | result = 1; | ||
452 | ammunition_integer_to_string( 4, d, s ); | ||
453 | ammunition_sprintf_d( str, ( INT_MAX / 3 ) * 3 ); | ||
454 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
455 | result = 1; | ||
456 | ammunition_sprintf_d( str, INT_MIN / 2 ); | ||
457 | ammunition_integer_from_string ( 4, str, d ); | ||
458 | ammunition_sprintf_d( str, 2 ); | ||
459 | ammunition_integer_from_string ( 4, str, e ); | ||
460 | ammunition_multiply_integer ( 4, d, e, d ); | ||
461 | if ( ammunition_overflow_bit ) | ||
462 | result = 1; | ||
463 | ammunition_integer_to_string( 4, d, s ); | ||
464 | ammunition_sprintf_d( str, ( INT_MIN / 2 ) * 2 ); | ||
465 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
466 | result = 1; | ||
467 | _Pragma( "loopbound min 4000 max 4000" ) | ||
468 | for ( i = -2000; i < 2000 ; i++ ) { | ||
469 | ammunition_sprintf_d( str, i ); | ||
470 | ammunition_integer_from_string ( 4, str, d ); | ||
471 | ammunition_sprintf_d( str, i + 1000 ); | ||
472 | ammunition_integer_from_string ( 4, str, e ); | ||
473 | ammunition_multiply_integer ( 4, d, e, d ); | ||
474 | if ( ammunition_overflow_bit ) | ||
475 | result = 1; | ||
476 | ammunition_integer_to_string( 4, d, s ); | ||
477 | if ( ammunition_atoi ( s ) != i * ( i + 1000 ) ) | ||
478 | result = 1; | ||
479 | } | ||
480 | |||
481 | /* Test 8 */ | ||
482 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
483 | |||
484 | ammunition_sprintf_u( str, UINT_MAX / 5 + 1 ); | ||
485 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
486 | ammunition_sprintf_u( str, 5 ); | ||
487 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
488 | ammunition_multiply_unsigned_integer ( 4, d, e, d ); | ||
489 | if ( !ammunition_overflow_bit ) | ||
490 | result = 1; | ||
491 | ammunition_sprintf_u( str, UINT_MAX / 2 ); | ||
492 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
493 | ammunition_sprintf_u( str, 2 ); | ||
494 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
495 | ammunition_multiply_unsigned_integer ( 4, d, e, d ); | ||
496 | if ( ammunition_overflow_bit ) | ||
497 | result = 1; | ||
498 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
499 | ammunition_sprintf_u( str, ( UINT_MAX / 2 ) * 2 ); | ||
500 | if ( ammunition_strcmp ( s, str ) != 0 ) | ||
501 | result = 1; | ||
502 | _Pragma( "loopbound min 4000 max 4000" ) | ||
503 | for ( i = 0; i < 4000 ; i++ ) { | ||
504 | ammunition_sprintf_u( str, i ); | ||
505 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
506 | ammunition_sprintf_u( str, i / 2 ); | ||
507 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
508 | ammunition_multiply_unsigned_integer ( 4, d, e, d ); | ||
509 | if ( ammunition_overflow_bit ) | ||
510 | result = 1; | ||
511 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
512 | if ( ammunition_atoi ( s ) != i * ( i / 2 ) ) | ||
513 | result = 1; | ||
514 | } | ||
515 | |||
516 | /* Test 9 */ | ||
517 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
518 | |||
519 | ammunition_integer_from_string ( 4, "10", d ); | ||
520 | ammunition_integer_from_string ( 4, "0", e ); | ||
521 | ammunition_divide_integer ( 4, d, e, d ); | ||
522 | if ( !ammunition_overflow_bit ) | ||
523 | result = 1; | ||
524 | _Pragma( "loopbound min 4000 max 4000" ) | ||
525 | for ( i = -2000; i < 2000 ; i++ ) { | ||
526 | ammunition_sprintf_d( str, i ); | ||
527 | ammunition_integer_from_string ( 4, str, d ); | ||
528 | ammunition_sprintf_d( str, ( i < 0 ? - i / 20 + 1 : - i / 20 - 1 ) ); | ||
529 | ammunition_integer_from_string ( 4, str, e ); | ||
530 | ammunition_divide_integer ( 4, d, e, d ); | ||
531 | if ( ammunition_overflow_bit ) | ||
532 | result = 1; | ||
533 | ammunition_integer_to_string( 4, d, s ); | ||
534 | if ( ammunition_atoi ( s ) != i / ( i < 0 ? - i / 20 + 1 : - i / 20 - 1 ) ) | ||
535 | result = 1; | ||
536 | ammunition_sprintf_d( str, i ); | ||
537 | ammunition_integer_from_string ( 4, str, d ); | ||
538 | ammunition_divide_integer ( 4, d, e, e ); | ||
539 | if ( ammunition_overflow_bit ) | ||
540 | result = 1; | ||
541 | ammunition_integer_to_string( 4, e, s ); | ||
542 | if ( ammunition_atoi ( s ) != i / ( i < 0 ? - i / 20 + 1 : - i / 20 - 1 ) ) | ||
543 | result = 1; | ||
544 | } | ||
545 | |||
546 | /* Test 10 */ | ||
547 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
548 | |||
549 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
550 | ammunition_unsigned_integer_from_string ( 4, "0", e ); | ||
551 | ammunition_divide_unsigned_integer ( 4, d, e, d ); | ||
552 | if ( !ammunition_overflow_bit ) | ||
553 | result = 1; | ||
554 | _Pragma( "loopbound min 4000 max 4000" ) | ||
555 | for ( i = 0; i < 4000 ; i++ ) { | ||
556 | ammunition_sprintf_u( str, i ); | ||
557 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
558 | ammunition_sprintf_u( str, i / 20 + 1 ); | ||
559 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
560 | ammunition_divide_unsigned_integer ( 4, d, e, d ); | ||
561 | if ( ammunition_overflow_bit ) | ||
562 | result = 1; | ||
563 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
564 | if ( ammunition_atoi ( s ) != i / ( i / 20 + 1 ) ) | ||
565 | result = 1; | ||
566 | } | ||
567 | |||
568 | /* Test 11 */ | ||
569 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
570 | |||
571 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
572 | ammunition_unsigned_integer_from_string ( 4, "0", e ); | ||
573 | ammunition_unsigned_integer_remainder ( 4, d, e, d ); | ||
574 | if ( !ammunition_overflow_bit ) | ||
575 | result = 1; | ||
576 | _Pragma( "loopbound min 4000 max 4000" ) | ||
577 | for ( i = 0; i < 4000 ; i++ ) { | ||
578 | ammunition_sprintf_u( str, i ); | ||
579 | ammunition_unsigned_integer_from_string ( 4, str, d ); | ||
580 | ammunition_sprintf_u( str, i / 20 + 1 ); | ||
581 | ammunition_unsigned_integer_from_string ( 4, str, e ); | ||
582 | ammunition_unsigned_integer_remainder ( 4, d, e, d ); | ||
583 | if ( ammunition_overflow_bit ) | ||
584 | result = 1; | ||
585 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
586 | if ( ammunition_atoi ( s ) != i % ( i / 20 + 1 ) ) | ||
587 | result = 1; | ||
588 | } | ||
589 | |||
590 | /* Test 12 */ | ||
591 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
592 | |||
593 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
594 | ammunition_unsigned_integer_shift_right ( 4, d, 0, d ); | ||
595 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
596 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1348" ) != 0 ) | ||
597 | result = 1; | ||
598 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
599 | ammunition_unsigned_integer_shift_right ( 4, d, 32, d ); | ||
600 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
601 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "0" ) != 0 ) | ||
602 | result = 1; | ||
603 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
604 | ammunition_unsigned_integer_shift_right ( 4, d, 8, d ); | ||
605 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
606 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "5" ) != 0 ) | ||
607 | result = 1; | ||
608 | ammunition_unsigned_integer_from_string ( 4, "134890", d ); | ||
609 | ammunition_unsigned_integer_shift_right ( 4, d, 13, d ); | ||
610 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
611 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "16" ) != 0 ) | ||
612 | result = 1; | ||
613 | ammunition_unsigned_integer_from_string ( 4, "134890", d ); | ||
614 | ammunition_unsigned_integer_shift_left ( 4, d, -13, d ); | ||
615 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
616 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "16" ) != 0 ) | ||
617 | result = 1; | ||
618 | |||
619 | /* Test 13 */ | ||
620 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
621 | |||
622 | ammunition_integer_from_string ( 4, "1348", d ); | ||
623 | ammunition_integer_shift_right ( 4, d, 0, d ); | ||
624 | ammunition_integer_to_string( 4, d, s ); | ||
625 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1348" ) != 0 ) | ||
626 | result = 1; | ||
627 | ammunition_integer_from_string ( 4, "1348", d ); | ||
628 | ammunition_integer_shift_right ( 4, d, 32, d ); | ||
629 | ammunition_integer_to_string( 4, d, s ); | ||
630 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "0" ) != 0 ) | ||
631 | result = 1; | ||
632 | ammunition_integer_from_string ( 4, "1348", d ); | ||
633 | ammunition_integer_shift_right ( 4, d, 8, d ); | ||
634 | ammunition_integer_to_string( 4, d, s ); | ||
635 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "5" ) != 0 ) | ||
636 | result = 1; | ||
637 | ammunition_integer_from_string ( 4, "134890", d ); | ||
638 | ammunition_integer_shift_right ( 4, d, 13, d ); | ||
639 | ammunition_integer_to_string( 4, d, s ); | ||
640 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "16" ) != 0 ) | ||
641 | result = 1; | ||
642 | ammunition_integer_from_string ( 4, "134890", d ); | ||
643 | ammunition_integer_shift_left ( 4, d, -13, d ); | ||
644 | ammunition_integer_to_string( 4, d, s ); | ||
645 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "16" ) != 0 ) | ||
646 | result = 1; | ||
647 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
648 | ammunition_integer_shift_right ( 4, d, 0, d ); | ||
649 | ammunition_integer_to_string( 4, d, s ); | ||
650 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "-1348" ) != 0 ) | ||
651 | result = 1; | ||
652 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
653 | ammunition_integer_shift_right ( 4, d, 32, d ); | ||
654 | ammunition_integer_to_string( 4, d, s ); | ||
655 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "-1" ) != 0 ) | ||
656 | result = 1; | ||
657 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
658 | ammunition_integer_shift_right ( 4, d, 8, d ); | ||
659 | ammunition_integer_to_string( 4, d, s ); | ||
660 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "-6" ) != 0 ) | ||
661 | result = 1; | ||
662 | ammunition_integer_from_string ( 4, "-134890", d ); | ||
663 | ammunition_integer_shift_right ( 4, d, 13, d ); | ||
664 | ammunition_integer_to_string( 4, d, s ); | ||
665 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "-17" ) != 0 ) | ||
666 | result = 1; | ||
667 | ammunition_integer_from_string ( 4, "-134890", d ); | ||
668 | ammunition_integer_shift_left ( 4, d, -13, d ); | ||
669 | ammunition_integer_to_string( 4, d, s ); | ||
670 | if ( !ammunition_overflow_bit || ammunition_strcmp ( s, "-17" ) != 0 ) | ||
671 | result = 1; | ||
672 | |||
673 | /* Test 14 */ | ||
674 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
675 | |||
676 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
677 | ammunition_unsigned_integer_shift_left ( 4, d, 0, d ); | ||
678 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
679 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1348" ) != 0 ) | ||
680 | result = 1; | ||
681 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
682 | ammunition_unsigned_integer_shift_left ( 4, d, 22, d ); | ||
683 | if ( !ammunition_overflow_bit ) | ||
684 | result = 1; | ||
685 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
686 | ammunition_unsigned_integer_shift_left ( 4, d, 8, d ); | ||
687 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
688 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "345088" ) != 0 ) | ||
689 | result = 1; | ||
690 | ammunition_unsigned_integer_from_string ( 4, "134890", d ); | ||
691 | ammunition_unsigned_integer_shift_left ( 4, d, 13, d ); | ||
692 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
693 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1105018880" ) != 0 ) | ||
694 | result = 1; | ||
695 | ammunition_unsigned_integer_from_string ( 4, "134890", d ); | ||
696 | ammunition_unsigned_integer_shift_right ( 4, d, -13, d ); | ||
697 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
698 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1105018880" ) != 0 ) | ||
699 | result = 1; | ||
700 | |||
701 | /* Test 15 */ | ||
702 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
703 | |||
704 | ammunition_integer_from_string ( 4, "1348", d ); | ||
705 | ammunition_integer_shift_left ( 4, d, 0, d ); | ||
706 | ammunition_integer_to_string( 4, d, s ); | ||
707 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1348" ) != 0 ) | ||
708 | result = 1; | ||
709 | ammunition_integer_from_string ( 4, "1348", d ); | ||
710 | ammunition_integer_shift_left ( 4, d, 21, d ); | ||
711 | if ( !ammunition_overflow_bit ) | ||
712 | result = 1; | ||
713 | ammunition_integer_from_string ( 4, "1348", d ); | ||
714 | ammunition_integer_shift_left ( 4, d, 8, d ); | ||
715 | ammunition_integer_to_string( 4, d, s ); | ||
716 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "345088" ) != 0 ) | ||
717 | result = 1; | ||
718 | ammunition_integer_from_string ( 4, "134890", d ); | ||
719 | ammunition_integer_shift_left ( 4, d, 13, d ); | ||
720 | ammunition_integer_to_string( 4, d, s ); | ||
721 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1105018880" ) != 0 ) | ||
722 | result = 1; | ||
723 | ammunition_integer_from_string ( 4, "134890", d ); | ||
724 | ammunition_integer_shift_right ( 4, d, -13, d ); | ||
725 | ammunition_integer_to_string( 4, d, s ); | ||
726 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "1105018880" ) != 0 ) | ||
727 | result = 1; | ||
728 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
729 | ammunition_integer_shift_left ( 4, d, 0, d ); | ||
730 | ammunition_integer_to_string( 4, d, s ); | ||
731 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "-1348" ) != 0 ) | ||
732 | result = 1; | ||
733 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
734 | ammunition_integer_shift_left ( 4, d, 21, d ); | ||
735 | if ( !ammunition_overflow_bit ) | ||
736 | result = 1; | ||
737 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
738 | ammunition_integer_shift_left ( 4, d, 8, d ); | ||
739 | ammunition_integer_to_string( 4, d, s ); | ||
740 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "-345088" ) != 0 ) | ||
741 | result = 1; | ||
742 | ammunition_integer_from_string ( 4, "-134890", d ); | ||
743 | ammunition_integer_shift_left ( 4, d, 13, d ); | ||
744 | ammunition_integer_to_string( 4, d, s ); | ||
745 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "-1105018880" ) != 0 ) | ||
746 | result = 1; | ||
747 | ammunition_integer_from_string ( 4, "-134890", d ); | ||
748 | ammunition_integer_shift_right ( 4, d, -13, d ); | ||
749 | ammunition_integer_to_string( 4, d, s ); | ||
750 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "-1105018880" ) != 0 ) | ||
751 | result = 1; | ||
752 | |||
753 | /* Test 16 */ | ||
754 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
755 | |||
756 | ammunition_integer_from_string ( 4, "-10", d ); | ||
757 | ammunition_integer_from_string ( 4, "1348", e ); | ||
758 | if ( ammunition_eq_integer ( 4, d, e ) ) | ||
759 | result = 1; | ||
760 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
761 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
762 | if ( !ammunition_eq_integer ( 4, d, e ) ) | ||
763 | result = 1; | ||
764 | |||
765 | /* Test 17 */ | ||
766 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
767 | |||
768 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
769 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
770 | if ( ammunition_eq_unsigned_integer ( 4, d, e ) ) | ||
771 | result = 1; | ||
772 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
773 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
774 | if ( !ammunition_eq_unsigned_integer ( 4, d, e ) ) | ||
775 | result = 1; | ||
776 | |||
777 | /* Test 18 */ | ||
778 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
779 | |||
780 | ammunition_integer_from_string ( 4, "-10", d ); | ||
781 | ammunition_integer_from_string ( 4, "1348", e ); | ||
782 | if ( !ammunition_ne_integer ( 4, d, e ) ) | ||
783 | result = 1; | ||
784 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
785 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
786 | if ( ammunition_ne_integer ( 4, d, e ) ) | ||
787 | result = 1; | ||
788 | |||
789 | /* Test 19 */ | ||
790 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
791 | |||
792 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
793 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
794 | if ( !ammunition_ne_unsigned_integer ( 4, d, e ) ) | ||
795 | result = 1; | ||
796 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
797 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
798 | if ( ammunition_ne_unsigned_integer ( 4, d, e ) ) | ||
799 | result = 1; | ||
800 | |||
801 | /* Test 20 */ | ||
802 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
803 | |||
804 | ammunition_integer_from_string ( 4, "-10", d ); | ||
805 | ammunition_integer_from_string ( 4, "1348", e ); | ||
806 | if ( ammunition_gt_integer ( 4, d, e ) ) | ||
807 | result = 1; | ||
808 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
809 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
810 | if ( ammunition_gt_integer ( 4, d, e ) ) | ||
811 | result = 1; | ||
812 | ammunition_integer_from_string ( 4, "-1000000", d ); | ||
813 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
814 | if ( ammunition_gt_integer ( 4, d, e ) ) | ||
815 | result = 1; | ||
816 | ammunition_integer_from_string ( 4, "1000000", d ); | ||
817 | ammunition_integer_from_string ( 4, "1348", e ); | ||
818 | if ( !ammunition_gt_integer ( 4, d, e ) ) | ||
819 | result = 1; | ||
820 | |||
821 | /* Test 21 */ | ||
822 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
823 | |||
824 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
825 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
826 | if ( ammunition_gt_unsigned_integer ( 4, d, e ) ) | ||
827 | result = 1; | ||
828 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
829 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
830 | if ( ammunition_gt_unsigned_integer ( 4, d, e ) ) | ||
831 | result = 1; | ||
832 | ammunition_unsigned_integer_from_string ( 4, "1000000", d ); | ||
833 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
834 | if ( !ammunition_gt_unsigned_integer ( 4, d, e ) ) | ||
835 | result = 1; | ||
836 | |||
837 | /* Test 22 */ | ||
838 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
839 | |||
840 | ammunition_integer_from_string ( 4, "-10", d ); | ||
841 | ammunition_integer_from_string ( 4, "1348", e ); | ||
842 | if ( !ammunition_lt_integer ( 4, d, e ) ) | ||
843 | result = 1; | ||
844 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
845 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
846 | if ( ammunition_lt_integer ( 4, d, e ) ) | ||
847 | result = 1; | ||
848 | ammunition_integer_from_string ( 4, "-1000000", d ); | ||
849 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
850 | if ( !ammunition_lt_integer ( 4, d, e ) ) | ||
851 | result = 1; | ||
852 | ammunition_integer_from_string ( 4, "1000000", d ); | ||
853 | ammunition_integer_from_string ( 4, "1348", e ); | ||
854 | if ( ammunition_lt_integer ( 4, d, e ) ) | ||
855 | result = 1; | ||
856 | |||
857 | /* Test 23 */ | ||
858 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
859 | |||
860 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
861 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
862 | if ( !ammunition_lt_unsigned_integer ( 4, d, e ) ) | ||
863 | result = 1; | ||
864 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
865 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
866 | if ( ammunition_lt_unsigned_integer ( 4, d, e ) ) | ||
867 | result = 1; | ||
868 | ammunition_unsigned_integer_from_string ( 4, "1000000", d ); | ||
869 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
870 | if ( ammunition_lt_unsigned_integer ( 4, d, e ) ) | ||
871 | result = 1; | ||
872 | |||
873 | /* Test 24 */ | ||
874 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
875 | |||
876 | ammunition_integer_from_string ( 4, "-10", d ); | ||
877 | ammunition_integer_from_string ( 4, "1348", e ); | ||
878 | if ( ammunition_ge_integer ( 4, d, e ) ) | ||
879 | result = 1; | ||
880 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
881 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
882 | if ( !ammunition_ge_integer ( 4, d, e ) ) | ||
883 | result = 1; | ||
884 | ammunition_integer_from_string ( 4, "-1000000", d ); | ||
885 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
886 | if ( ammunition_ge_integer ( 4, d, e ) ) | ||
887 | result = 1; | ||
888 | ammunition_integer_from_string ( 4, "1000000", d ); | ||
889 | ammunition_integer_from_string ( 4, "1348", e ); | ||
890 | if ( !ammunition_ge_integer ( 4, d, e ) ) | ||
891 | result = 1; | ||
892 | |||
893 | /* Test 25 */ | ||
894 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
895 | |||
896 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
897 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
898 | if ( ammunition_ge_unsigned_integer ( 4, d, e ) ) | ||
899 | result = 1; | ||
900 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
901 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
902 | if ( !ammunition_ge_unsigned_integer ( 4, d, e ) ) | ||
903 | result = 1; | ||
904 | ammunition_unsigned_integer_from_string ( 4, "1000000", d ); | ||
905 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
906 | if ( !ammunition_ge_unsigned_integer ( 4, d, e ) ) | ||
907 | result = 1; | ||
908 | |||
909 | /* Test 26 */ | ||
910 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
911 | |||
912 | ammunition_integer_from_string ( 4, "-10", d ); | ||
913 | ammunition_integer_from_string ( 4, "1348", e ); | ||
914 | if ( !ammunition_le_integer ( 4, d, e ) ) | ||
915 | result = 1; | ||
916 | ammunition_integer_from_string ( 4, "-1348", d ); | ||
917 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
918 | if ( !ammunition_le_integer ( 4, d, e ) ) | ||
919 | result = 1; | ||
920 | ammunition_integer_from_string ( 4, "-1000000", d ); | ||
921 | ammunition_integer_from_string ( 4, "-1348", e ); | ||
922 | if ( !ammunition_le_integer ( 4, d, e ) ) | ||
923 | result = 1; | ||
924 | ammunition_integer_from_string ( 4, "1000000", d ); | ||
925 | ammunition_integer_from_string ( 4, "1348", e ); | ||
926 | if ( ammunition_le_integer ( 4, d, e ) ) | ||
927 | result = 1; | ||
928 | |||
929 | /* Test 27 */ | ||
930 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
931 | |||
932 | ammunition_unsigned_integer_from_string ( 4, "10", d ); | ||
933 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
934 | if ( !ammunition_le_unsigned_integer ( 4, d, e ) ) | ||
935 | result = 1; | ||
936 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
937 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
938 | if ( !ammunition_le_unsigned_integer ( 4, d, e ) ) | ||
939 | result = 1; | ||
940 | ammunition_unsigned_integer_from_string ( 4, "1000000", d ); | ||
941 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
942 | if ( ammunition_le_unsigned_integer ( 4, d, e ) ) | ||
943 | result = 1; | ||
944 | |||
945 | /* Test 28 */ | ||
946 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
947 | |||
948 | ammunition_unsigned_integer_from_string ( 4, "70000", d ); | ||
949 | ammunition_change_unsigned_integer_size ( 4, d, 2, d ); | ||
950 | if ( !ammunition_overflow_bit ) | ||
951 | result = 1; | ||
952 | ammunition_unsigned_integer_from_string ( 4, "30000", d ); | ||
953 | ammunition_change_unsigned_integer_size ( 4, d, 2, d ); | ||
954 | ammunition_integer_to_string( 2, d, s ); | ||
955 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "30000" ) != 0 ) | ||
956 | result = 1; | ||
957 | ammunition_unsigned_integer_from_string ( 4, "11230000", g ); | ||
958 | ammunition_change_unsigned_integer_size ( 4, g, 6, g ); | ||
959 | ammunition_integer_to_string( 6, g, s ); | ||
960 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "11230000" ) != 0 ) | ||
961 | result = 1; | ||
962 | |||
963 | /* Test 29 */ | ||
964 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
965 | |||
966 | ammunition_integer_from_string ( 4, "40000", d ); | ||
967 | ammunition_change_integer_size ( 4, d, 2, d ); | ||
968 | if ( !ammunition_overflow_bit ) | ||
969 | result = 1; | ||
970 | ammunition_integer_from_string ( 4, "-33000", d ); | ||
971 | ammunition_change_integer_size ( 4, d, 2, d ); | ||
972 | if ( !ammunition_overflow_bit ) | ||
973 | result = 1; | ||
974 | ammunition_integer_from_string ( 4, "30000", d ); | ||
975 | ammunition_change_integer_size ( 4, d, 2, d ); | ||
976 | ammunition_integer_to_string( 2, d, s ); | ||
977 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "30000" ) != 0 ) | ||
978 | result = 1; | ||
979 | ammunition_integer_from_string ( 4, "-30000", d ); | ||
980 | ammunition_change_integer_size ( 4, d, 2, d ); | ||
981 | ammunition_integer_to_string( 2, d, s ); | ||
982 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "-30000" ) != 0 ) | ||
983 | result = 1; | ||
984 | ammunition_integer_from_string ( 4, "11230000", g ); | ||
985 | ammunition_change_integer_size ( 4, g, 6, g ); | ||
986 | ammunition_integer_to_string( 6, g, s ); | ||
987 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "11230000" ) != 0 ) | ||
988 | result = 1; | ||
989 | ammunition_integer_from_string ( 4, "-11230000", g ); | ||
990 | ammunition_change_integer_size ( 4, g, 6, g ); | ||
991 | ammunition_integer_to_string( 6, g, s ); | ||
992 | if ( ammunition_overflow_bit || ammunition_strcmp ( s, "-11230000" ) != 0 ) | ||
993 | result = 1; | ||
994 | |||
995 | /* Test 30 */ | ||
996 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
997 | |||
998 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
999 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
1000 | ammunition_unsigned_integer_or ( 4, d, e, e ); | ||
1001 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1002 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1003 | result = 1; | ||
1004 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1005 | ammunition_unsigned_integer_from_string ( 4, "0", e ); | ||
1006 | ammunition_unsigned_integer_or ( 4, d, e, e ); | ||
1007 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1008 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1009 | result = 1; | ||
1010 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1011 | ammunition_unsigned_integer_from_string ( 4, "4294967295", e ); | ||
1012 | ammunition_unsigned_integer_or ( 4, d, e, e ); | ||
1013 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1014 | if ( ammunition_strcmp ( s, "4294967295" ) != 0 ) | ||
1015 | result = 1; | ||
1016 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1017 | ammunition_unsigned_integer_from_string ( 4, "96", e ); | ||
1018 | ammunition_unsigned_integer_or ( 4, d, e, e ); | ||
1019 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1020 | if ( ammunition_strcmp ( s, "1380" ) != 0 ) | ||
1021 | result = 1; | ||
1022 | |||
1023 | /* Test 31 */ | ||
1024 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
1025 | |||
1026 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1027 | ammunition_integer_from_string ( 4, "1348", e ); | ||
1028 | ammunition_integer_or ( 4, d, e, e ); | ||
1029 | ammunition_integer_to_string( 4, e, s ); | ||
1030 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1031 | result = 1; | ||
1032 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1033 | ammunition_integer_from_string ( 4, "0", e ); | ||
1034 | ammunition_integer_or ( 4, d, e, e ); | ||
1035 | ammunition_integer_to_string( 4, e, s ); | ||
1036 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1037 | result = 1; | ||
1038 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1039 | ammunition_integer_from_string ( 4, "-1", e ); | ||
1040 | ammunition_integer_or ( 4, d, e, e ); | ||
1041 | ammunition_integer_to_string( 4, e, s ); | ||
1042 | if ( ammunition_strcmp ( s, "-1" ) != 0 ) | ||
1043 | result = 1; | ||
1044 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1045 | ammunition_integer_from_string ( 4, "96", e ); | ||
1046 | ammunition_integer_or ( 4, d, e, e ); | ||
1047 | ammunition_integer_to_string( 4, e, s ); | ||
1048 | if ( ammunition_strcmp ( s, "1380" ) != 0 ) | ||
1049 | result = 1; | ||
1050 | |||
1051 | /* Test 32 */ | ||
1052 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
1053 | |||
1054 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1055 | ammunition_unsigned_integer_from_string ( 4, "1348", e ); | ||
1056 | ammunition_unsigned_integer_and ( 4, d, e, e ); | ||
1057 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1058 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1059 | result = 1; | ||
1060 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1061 | ammunition_unsigned_integer_from_string ( 4, "0", e ); | ||
1062 | ammunition_unsigned_integer_and ( 4, d, e, e ); | ||
1063 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1064 | if ( ammunition_strcmp ( s, "0" ) != 0 ) | ||
1065 | result = 1; | ||
1066 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1067 | ammunition_unsigned_integer_from_string ( 4, "4294967295", e ); | ||
1068 | ammunition_unsigned_integer_and ( 4, d, e, e ); | ||
1069 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1070 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1071 | result = 1; | ||
1072 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1073 | ammunition_unsigned_integer_from_string ( 4, "96", e ); | ||
1074 | ammunition_unsigned_integer_and ( 4, d, e, e ); | ||
1075 | ammunition_unsigned_integer_to_string ( 4, e, s ); | ||
1076 | if ( ammunition_strcmp ( s, "64" ) != 0 ) | ||
1077 | result = 1; | ||
1078 | |||
1079 | /* Test 33 */ | ||
1080 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
1081 | |||
1082 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1083 | ammunition_integer_from_string ( 4, "1348", e ); | ||
1084 | ammunition_integer_and ( 4, d, e, e ); | ||
1085 | ammunition_integer_to_string( 4, e, s ); | ||
1086 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1087 | result = 1; | ||
1088 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1089 | ammunition_integer_from_string ( 4, "0", e ); | ||
1090 | ammunition_integer_and ( 4, d, e, e ); | ||
1091 | ammunition_integer_to_string( 4, e, s ); | ||
1092 | if ( ammunition_strcmp ( s, "0" ) != 0 ) | ||
1093 | result = 1; | ||
1094 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1095 | ammunition_integer_from_string ( 4, "-1", e ); | ||
1096 | ammunition_integer_and ( 4, d, e, e ); | ||
1097 | ammunition_integer_to_string( 4, e, s ); | ||
1098 | if ( ammunition_strcmp ( s, "1348" ) != 0 ) | ||
1099 | result = 1; | ||
1100 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1101 | ammunition_integer_from_string ( 4, "96", e ); | ||
1102 | ammunition_integer_and ( 4, d, e, e ); | ||
1103 | ammunition_integer_to_string( 4, e, s ); | ||
1104 | if ( ammunition_strcmp ( s, "64" ) != 0 ) | ||
1105 | result = 1; | ||
1106 | |||
1107 | /* Test 34 */ | ||
1108 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
1109 | |||
1110 | ammunition_unsigned_integer_from_string ( 4, "1348", d ); | ||
1111 | ammunition_unsigned_integer_not ( 4, d, d ); | ||
1112 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
1113 | if ( ammunition_strcmp ( s, "4294965947" ) != 0 ) | ||
1114 | result = 1; | ||
1115 | ammunition_unsigned_integer_from_string ( 4, "0", d ); | ||
1116 | ammunition_unsigned_integer_not ( 4, d, d ); | ||
1117 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
1118 | if ( ammunition_strcmp ( s, "4294967295" ) != 0 ) | ||
1119 | result = 1; | ||
1120 | ammunition_unsigned_integer_from_string ( 4, "4294967295", d ); | ||
1121 | ammunition_unsigned_integer_not ( 4, d, d ); | ||
1122 | ammunition_unsigned_integer_to_string ( 4, d, s ); | ||
1123 | if ( ammunition_strcmp ( s, "0" ) != 0 ) | ||
1124 | result = 1; | ||
1125 | |||
1126 | /* Test 35 */ | ||
1127 | ammunition_reset_str_arithm( str, s, d, e, g ); | ||
1128 | |||
1129 | ammunition_integer_from_string ( 4, "1348", d ); | ||
1130 | ammunition_integer_not ( 4, d, d ); | ||
1131 | ammunition_integer_to_string( 4, d, s ); | ||
1132 | if ( ammunition_strcmp ( s, "-1349" ) != 0 ) | ||
1133 | result = 1; | ||
1134 | ammunition_integer_from_string ( 4, "0", d ); | ||
1135 | ammunition_integer_not ( 4, d, d ); | ||
1136 | ammunition_integer_to_string( 4, d, s ); | ||
1137 | if ( ammunition_strcmp ( s, "-1" ) != 0 ) | ||
1138 | result = 1; | ||
1139 | ammunition_integer_from_string ( 4, "-1", d ); | ||
1140 | ammunition_integer_not ( 4, d, d ); | ||
1141 | ammunition_integer_to_string( 4, d, s ); | ||
1142 | if ( ammunition_strcmp ( s, "0" ) != 0 ) | ||
1143 | result = 1; | ||
1144 | |||
1145 | return result; | ||
1146 | } | ||
1147 | |||
1148 | |||
1149 | /* | ||
1150 | Initialization- and return-value-related functions | ||
1151 | */ | ||
1152 | |||
1153 | void ammunition_init( void ) | ||
1154 | { | ||
1155 | ammunition_result = 0; | ||
1156 | } | ||
1157 | |||
1158 | int ammunition_return( void ) | ||
1159 | { | ||
1160 | return ammunition_result; | ||
1161 | } | ||
1162 | |||
1163 | /* | ||
1164 | Main functions | ||
1165 | */ | ||
1166 | |||
1167 | void _Pragma( "entrypoint" ) ammunition_main( void ) | ||
1168 | { | ||
1169 | ammunition_result |= ammunition_bits_test(); | ||
1170 | ammunition_result |= ammunition_arithm_test(); | ||
1171 | } | ||
1172 | |||
1173 | |||
1174 | int main( int argc, char **argv ) | ||
1175 | { | ||
1176 | SET_UP | ||
1177 | for (jobsComplete=-1; jobsComplete<maxJobs; jobsComplete++){ | ||
1178 | START_LOOP | ||
1179 | ammunition_init(); | ||
1180 | ammunition_main(); | ||
1181 | STOP_LOOP | ||
1182 | } | ||
1183 | WRITE_TO_FILE | ||
1184 | return ( ammunition_return() ); | ||
1185 | } | ||