5 #include "aros_types.h"
7 void hexdump (const void * start
, int size
);
9 /* Make sure that all variables contain the same values */
10 #define __check(v1,op,v2) \
13 printf ("Check: " #v1 " " #op " " #v2 "\n"); \
14 hexdump (&v1, sizeof (v1)); \
15 hexdump (&v2, sizeof (v2)); \
19 printf ("%s:%d: Check failed: " #v1 " " #op " " #v2 " (%d - %d)\n", \
20 __FILE__, __LINE__, (int)v1, (int)v2); \
31 #define unoptest(op) \
32 s op; us op; l op; ul op; \
33 w op; uw op; L op; UL op; \
36 #define binoptest(op) \
37 s = s op; us = us op; l = l op; ul = ul op; \
38 w = w op; uw = uw op; L = L op; UL = UL op; \
41 #define cmptest(v1,op,v2) \
42 s = v1; us = v1; l = v1; ul = v1; \
43 w = v2; uw = v2; L = v2; UL = v2; \
46 int main (int argc
, char ** argv
)
57 int debug
= (argc
!= 1);
60 hexdump (&test
, sizeof (test
));
62 printf ("Check assignments\n");
65 unoptest (= 0x12345678);
66 unoptest (= 0x92345678);
67 w
= s
; uw
= us
; L
= l
; UL
= ul
; check (==);
68 s
= w
; us
= uw
; l
= L
; ul
= UL
; check (==);
70 printf ("Check + operator\n");
74 binoptest (+ 0x12345678);
75 binoptest (+ 0x92345678);
77 printf ("Check - operator\n");
81 binoptest (- 0x12345678);
82 binoptest (- 0x92345678);
84 printf ("Check * operator\n");
88 binoptest (* 0x12345678);
89 binoptest (* 0x92345678);
91 printf ("Check / operator\n");
95 binoptest (/ 0x12345678);
96 binoptest (/ 0x92345678);
98 printf ("Check %% operator\n");
100 binoptest (% 0x1234);
101 binoptest (% 0x9234);
102 binoptest (% 0x12345678);
103 binoptest (% 0x92345678);
105 printf ("Check >> operator\n");
106 unoptest (= 0x12345678);
109 printf ("Check << operator\n");
110 unoptest (= 0x12345678);
113 printf ("Check < comparison\n");
114 cmptest (0x12345678, <, 0x12345679);
115 cmptest (0x12345678, <=, 0x12345679);
116 cmptest (0x12345678, <=, 0x12345678);
118 printf ("Check > comparison\n");
119 cmptest (0x12345679, >, 0x12345678);
120 cmptest (0x12345679, >=, 0x12345678);
121 cmptest (0x12345678, >=, 0x12345678);
123 printf ("All tests succeeded\n");
127 /* Print the contents of a piece of memory. */
128 void hexdump (const void * start
, int size
)
131 const unsigned char * ptr
= (const unsigned char *)start
;
133 for (t
=0; size
> 0; t
++, size
--)
135 if (!(t
& 15)) printf ("%08lx: ", ((long)ptr
));
136 printf ("%02x", *ptr
++);
137 if ((t
& 3) == 3) putchar (' ');
138 if ((t
& 15) == 15) putchar ('\n');
141 if (t
& 15) putchar ('\n');