Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / iso646.c.in
blobb8e0fab57482f7e89c9d36d629181c14df13eb5f
1 /** Test iso 646
3 type: char, short, long
4 attr: volatile,
5 storage: static,
6 */
7 #include <testfwk.h>
9 #include <float.h> /* bug #2314 was a conflict between iso646.h and float.h */
10 #include <iso646.h>
12 static void
13 testTwoOpBitwise(void)
15 #if !defined(__SDCC_pdk14) // Lack of memory
16 {storage} {attr} {type} left, right;
18 left = ({type})0x3df7;
19 right = ({type})0xc1ec;
21 ASSERT(({type})(left bitand right) == ({type})0x1E4);
22 ASSERT(({type})(right bitand left) == ({type})0x1E4);
23 ASSERT(({type})(left bitand 0xc1ec) == ({type})0x1E4);
24 ASSERT(({type})(0x3df7 bitand right) == ({type})0x1E4);
26 ASSERT(({type})(left bitor right) == ({type})0xFDFF);
27 ASSERT(({type})(right bitor left) == ({type})0xFDFF);
28 ASSERT(({type})(left bitor 0xc1ec) == ({type})0xFDFF);
29 ASSERT(({type})(0x3df7 bitor right) == ({type})0xFDFF);
31 ASSERT(({type})(left xor right) == ({type})0xFC1B);
32 ASSERT(({type})(right xor left) == ({type})0xFC1B);
33 ASSERT(({type})(left xor 0xc1ec) == ({type})0xFC1B);
34 ASSERT(({type})(0x3df7 xor right) == ({type})0xFC1B);
35 #endif
38 static {type}
39 alwaysTrue(void)
41 return ({type})1;
44 static {type}
45 alwaysFalse(void)
47 return 0;
50 static void
51 testNot(void)
53 {type} true = alwaysTrue();
54 {type} false = alwaysFalse();
56 ASSERT(not false);
57 ASSERT(not not true);
58 ASSERT(not not not false);
59 ASSERT(true not_eq false);
62 static void
63 testUnary(void)
65 int i;
66 ASSERT(compl 0xaa55 == ~0xaa55);
67 ASSERT(bitand i == &i);