2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
9 #include "aros_types.h"
11 void hexdump (const void * start
, int size
);
13 /* Make sure that all variables contain the same values */
14 #define __check(v1,op,v2) \
17 printf ("Check: " #v1 " " #op " " #v2 "\n"); \
18 hexdump (&v1, sizeof (v1)); \
19 hexdump (&v2, sizeof (v2)); \
23 printf ("%s:%d: Check failed: " #v1 " " #op " " #v2 " (%d - %d)\n", \
24 __FILE__, __LINE__, (int)v1, (int)v2); \
35 #define unoptest(op) \
36 s op; us op; l op; ul op; \
37 w op; uw op; L op; UL op; \
40 #define binoptest(op) \
41 s = s op; us = us op; l = l op; ul = ul op; \
42 w = w op; uw = uw op; L = L op; UL = UL op; \
45 #define cmptest(v1,op,v2) \
46 s = v1; us = v1; l = v1; ul = v1; \
47 w = v2; uw = v2; L = v2; UL = v2; \
50 int main (int argc
, char ** argv
)
61 int debug
= (argc
!= 1);
64 hexdump (&test
, sizeof (test
));
66 printf ("Check assignments\n");
69 unoptest (= 0x12345678);
70 unoptest (= 0x92345678);
71 w
= s
; uw
= us
; L
= l
; UL
= ul
; check (==);
72 s
= w
; us
= uw
; l
= L
; ul
= UL
; check (==);
74 printf ("Check + operator\n");
78 binoptest (+ 0x12345678);
79 binoptest (+ 0x92345678);
81 printf ("Check - operator\n");
85 binoptest (- 0x12345678);
86 binoptest (- 0x92345678);
88 printf ("Check * operator\n");
92 binoptest (* 0x12345678);
93 binoptest (* 0x92345678);
95 printf ("Check / operator\n");
99 binoptest (/ 0x12345678);
100 binoptest (/ 0x92345678);
102 printf ("Check %% operator\n");
104 binoptest (% 0x1234);
105 binoptest (% 0x9234);
106 binoptest (% 0x12345678);
107 binoptest (% 0x92345678);
109 printf ("Check >> operator\n");
110 unoptest (= 0x12345678);
113 printf ("Check << operator\n");
114 unoptest (= 0x12345678);
117 printf ("Check < comparison\n");
118 cmptest (0x12345678, <, 0x12345679);
119 cmptest (0x12345678, <=, 0x12345679);
120 cmptest (0x12345678, <=, 0x12345678);
122 printf ("Check > comparison\n");
123 cmptest (0x12345679, >, 0x12345678);
124 cmptest (0x12345679, >=, 0x12345678);
125 cmptest (0x12345678, >=, 0x12345678);
127 printf ("All tests succeeded\n");
131 /* Print the contents of a piece of memory. */
132 void hexdump (const void * start
, int size
)
135 const unsigned char * ptr
= (const unsigned char *)start
;
137 for (t
=0; size
> 0; t
++, size
--)
139 if (!(t
& 15)) printf ("%08lx: ", ((long)ptr
));
140 printf ("%02x", *ptr
++);
141 if ((t
& 3) == 3) putchar (' ');
142 if ((t
& 15) == 15) putchar ('\n');
145 if (t
& 15) putchar ('\n');