struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / getbyte.c.in
blob142db5939589194cb0e6f8be235f6c5852f785f2
1 /* getbyte/getword
2 sign: unsigned, signed
3 */
5 #include <testfwk.h>
6 #include <stdint.h>
8 {sign} long global = ({sign} long)0x12345678;
10 void testGet(void)
12 ASSERT (((global >> 0) & 0xFF) == 0x78); // getByte 0
13 ASSERT (((global >> 8) & 0xFF) == 0x56); // getByte 1
14 ASSERT (((global >> 16) & 0xFF) == 0x34); // getByte 2
15 ASSERT (((global >> 24) & 0xFF) == 0x12); // getByte 3
16 #if !defined(__SDCC_pdk14) // Lack of memory - see RFE #617.
17 ASSERT (((global >> 0) & 0xFFFF) == 0x5678); // getWord 0
18 ASSERT (((global >> 8) & 0xFFFF) == 0x3456); // getWord 1
19 ASSERT (((global >> 16) & 0xFFFF) == 0x1234); // getWord 2
21 ASSERT ((uint8_t)(global >> 0) == (uint8_t)0x78); // getByte 0
22 ASSERT ((uint8_t)(global >> 8) == (uint8_t)0x56); // getByte 1
23 ASSERT ((uint8_t)(global >> 16) == (uint8_t)0x34); // getByte 2
24 ASSERT ((uint8_t)(global >> 24) == (uint8_t)0x12); // getByte 3
26 ASSERT ((uint16_t)(global >> 0) == (uint16_t)0x5678); // getWord 0
27 ASSERT ((uint16_t)(global >> 8) == (uint16_t)0x3456); // getWord 1
28 ASSERT ((uint16_t)(global >> 16) == (uint16_t)0x1234); // getWord 2
29 #endif