add dxtn support library api for runtime s3tc
[AROS.git] / test / uae-tmpl / test-1.c
blobef2b0773c90e03e5ba68721693e19c02b954d2aa
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <assert.h>
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) \
15 if (debug) \
16 { \
17 printf ("Check: " #v1 " " #op " " #v2 "\n"); \
18 hexdump (&v1, sizeof (v1)); \
19 hexdump (&v2, sizeof (v2)); \
20 } \
21 if (!(v1 op v2) ) \
22 { \
23 printf ("%s:%d: Check failed: " #v1 " " #op " " #v2 " (%d - %d)\n", \
24 __FILE__, __LINE__, (int)v1, (int)v2); \
26 #define check(op) \
27 do { \
28 __check (s,op,w) \
29 __check (us,op,uw) \
30 __check (l,op,L) \
31 __check (ul,op,UL) \
32 } \
33 while (0)
35 #define unoptest(op) \
36 s op; us op; l op; ul op; \
37 w op; uw op; L op; UL op; \
38 check (==)
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; \
43 check (==)
45 #define cmptest(v1,op,v2) \
46 s = v1; us = v1; l = v1; ul = v1; \
47 w = v2; uw = v2; L = v2; UL = v2; \
48 check (op)
50 int main (int argc, char ** argv)
52 short s;
53 unsigned short us;
54 long l;
55 unsigned long ul;
56 WORD w;
57 UWORD uw;
58 LONG L;
59 ULONG UL;
61 int debug = (argc != 1);
63 int test = 0x123456;
64 hexdump (&test, sizeof (test));
66 printf ("Check assignments\n");
67 unoptest (= 0);
68 unoptest (= 0x1234);
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");
75 binoptest (+ 1);
76 binoptest (+ 0x1234);
77 binoptest (+ 0x9234);
78 binoptest (+ 0x12345678);
79 binoptest (+ 0x92345678);
81 printf ("Check - operator\n");
82 binoptest (- 1);
83 binoptest (- 0x1234);
84 binoptest (- 0x9234);
85 binoptest (- 0x12345678);
86 binoptest (- 0x92345678);
88 printf ("Check * operator\n");
89 binoptest (* 2);
90 binoptest (* 0x1234);
91 binoptest (* 0x9234);
92 binoptest (* 0x12345678);
93 binoptest (* 0x92345678);
95 printf ("Check / operator\n");
96 binoptest (/ 2);
97 binoptest (/ 0x1234);
98 binoptest (/ 0x9234);
99 binoptest (/ 0x12345678);
100 binoptest (/ 0x92345678);
102 printf ("Check %% operator\n");
103 binoptest (% 2);
104 binoptest (% 0x1234);
105 binoptest (% 0x9234);
106 binoptest (% 0x12345678);
107 binoptest (% 0x92345678);
109 printf ("Check >> operator\n");
110 unoptest (= 0x12345678);
111 binoptest (>> 2);
113 printf ("Check << operator\n");
114 unoptest (= 0x12345678);
115 binoptest (<< 2);
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");
128 exit (0);
131 /* Print the contents of a piece of memory. */
132 void hexdump (const void * start, int size)
134 int t;
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');