Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / test / uae-tmpl / test-1.c
blob8ecbf921d62a3ca8c9dbf6d22d58fdd68fdf0951
2 #include <stdio.h>
3 #include <assert.h>
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) \
11 if (debug) \
12 { \
13 printf ("Check: " #v1 " " #op " " #v2 "\n"); \
14 hexdump (&v1, sizeof (v1)); \
15 hexdump (&v2, sizeof (v2)); \
16 } \
17 if (!(v1 op v2) ) \
18 { \
19 printf ("%s:%d: Check failed: " #v1 " " #op " " #v2 " (%d - %d)\n", \
20 __FILE__, __LINE__, (int)v1, (int)v2); \
22 #define check(op) \
23 do { \
24 __check (s,op,w) \
25 __check (us,op,uw) \
26 __check (l,op,L) \
27 __check (ul,op,UL) \
28 } \
29 while (0)
31 #define unoptest(op) \
32 s op; us op; l op; ul op; \
33 w op; uw op; L op; UL op; \
34 check (==)
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; \
39 check (==)
41 #define cmptest(v1,op,v2) \
42 s = v1; us = v1; l = v1; ul = v1; \
43 w = v2; uw = v2; L = v2; UL = v2; \
44 check (op)
46 int main (int argc, char ** argv)
48 short s;
49 unsigned short us;
50 long l;
51 unsigned long ul;
52 WORD w;
53 UWORD uw;
54 LONG L;
55 ULONG UL;
57 int debug = (argc != 1);
59 int test = 0x123456;
60 hexdump (&test, sizeof (test));
62 printf ("Check assignments\n");
63 unoptest (= 0);
64 unoptest (= 0x1234);
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");
71 binoptest (+ 1);
72 binoptest (+ 0x1234);
73 binoptest (+ 0x9234);
74 binoptest (+ 0x12345678);
75 binoptest (+ 0x92345678);
77 printf ("Check - operator\n");
78 binoptest (- 1);
79 binoptest (- 0x1234);
80 binoptest (- 0x9234);
81 binoptest (- 0x12345678);
82 binoptest (- 0x92345678);
84 printf ("Check * operator\n");
85 binoptest (* 2);
86 binoptest (* 0x1234);
87 binoptest (* 0x9234);
88 binoptest (* 0x12345678);
89 binoptest (* 0x92345678);
91 printf ("Check / operator\n");
92 binoptest (/ 2);
93 binoptest (/ 0x1234);
94 binoptest (/ 0x9234);
95 binoptest (/ 0x12345678);
96 binoptest (/ 0x92345678);
98 printf ("Check %% operator\n");
99 binoptest (% 2);
100 binoptest (% 0x1234);
101 binoptest (% 0x9234);
102 binoptest (% 0x12345678);
103 binoptest (% 0x92345678);
105 printf ("Check >> operator\n");
106 unoptest (= 0x12345678);
107 binoptest (>> 2);
109 printf ("Check << operator\n");
110 unoptest (= 0x12345678);
111 binoptest (<< 2);
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");
124 exit (0);
127 /* Print the contents of a piece of memory. */
128 void hexdump (const void * start, int size)
130 int t;
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');