struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / uitobcd.c
blob4db0c3cad004806292fd9af8326a421c4afed959
1 /*
2 uitobcd.c
3 */
5 #include <testfwk.h>
6 #include <stdio.h>
8 extern void __uitobcd (unsigned int v, unsigned char r[3]);
9 #define CHECK(v) \
10 do { \
11 static const unsigned char u[3] = { 0x##v % 0x100, (0x##v / 0x100) % 0x100, (0x##v / 0x10000) % 0x100 }; \
12 unsigned char r[3] = { 0xff, 0xff, 0xff }; \
13 __uitobcd (v, r); \
14 unsigned long bcd = r[2] * 0x10000 + r[1] * 0x100 + r[0]; \
15 ASSERT ((#v,(r[0]==u[0]&&r[1]==u[1]&&r[2]==u[2]))); \
16 } while (0)
18 void test__uitobcd (void)
20 #if defined(__SDCC_z80)
21 CHECK(0);
22 CHECK(1);
23 CHECK(2);
24 CHECK(9);
25 CHECK(10);
26 CHECK(11);
27 CHECK(15);
28 CHECK(16);
29 CHECK(31);
30 CHECK(99);
31 CHECK(100);
32 CHECK(101);
33 CHECK(127);
34 CHECK(128);
35 CHECK(998);
36 CHECK(999);
37 CHECK(1000);
38 CHECK(1001);
39 CHECK(1023);
40 CHECK(1024);
41 CHECK(9998);
42 CHECK(9999);
43 CHECK(10000);
44 CHECK(10001);
45 CHECK(32767);
46 CHECK(32768);
47 CHECK(65535);
48 #endif