summaryrefslogtreecommitdiff
path: root/support/regression/tests/iso646.c
blob: 5709a741e31bd302ef2154c1dcfa7f8b35b4e041 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/** Test iso 646

    type: char, short, long
    attr: volatile,
    storage: static,
 */
#include <testfwk.h>

#include <float.h> /* bug #2314 was a conflict between iso646.h and float.h */
#include <iso646.h>

static void
testTwoOpBitwise(void)
{
#if !defined(__SDCC_pdk14) // Lack of memory
  {storage} {attr} {type} left, right;

  left = ({type})0x3df7;
  right = ({type})0xc1ec;

  ASSERT(({type})(left bitand right) == ({type})0x1E4);
  ASSERT(({type})(right bitand left) == ({type})0x1E4);
  ASSERT(({type})(left bitand 0xc1ec) == ({type})0x1E4);
  ASSERT(({type})(0x3df7 bitand right) == ({type})0x1E4);

  ASSERT(({type})(left bitor right) == ({type})0xFDFF);
  ASSERT(({type})(right bitor left) == ({type})0xFDFF);
  ASSERT(({type})(left bitor 0xc1ec) == ({type})0xFDFF);
  ASSERT(({type})(0x3df7 bitor right) == ({type})0xFDFF);

  ASSERT(({type})(left xor right) == ({type})0xFC1B);
  ASSERT(({type})(right xor left) == ({type})0xFC1B);
  ASSERT(({type})(left xor 0xc1ec) == ({type})0xFC1B);
  ASSERT(({type})(0x3df7 xor right) == ({type})0xFC1B);
#endif
}

static {type}
alwaysTrue(void)
{
    return ({type})1;
}

static {type}
alwaysFalse(void)
{
    return 0;
}

static void
testNot(void)
{
    {type} true = alwaysTrue();
    {type} false = alwaysFalse();

    ASSERT(not false);
    ASSERT(not not true);
    ASSERT(not not not false);
	ASSERT(true not_eq false);
}