* src/z80/gen.c (fetchLitPair): Changed so that it properly caches direct space...
[fw/sdcc] / support / regression / tests / addsub.c
1 /** Add, sub tests.
2
3     type: signed char, int, long
4     storage: static, 
5     attr: volatile
6 */
7 #include <testfwk.h>
8
9 void 
10 testAdd(void)
11 {
12   {storage} {attr} {type} left, right, result;
13
14   left = 5;
15   right = 26;
16
17   result = left+right;
18   ASSERT(result == 31);
19   
20   left = 39;
21   right = -120;
22   
23   result = left+right;
24   ASSERT(result == (39-120));
25
26   left = -39;
27   right = 80;
28   
29   result = left+right;
30   ASSERT(result == (-39+80));
31
32   left = -39;
33   right = -70;
34   
35   result = left+right;
36   ASSERT(result == (-39-70));
37 }
38
39 void 
40 testSub(void)
41 {
42   {storage} {attr} {type} left, right, result;
43
44   left = 5;
45   right = 26;
46
47   result = left-right;
48   ASSERT(result == (5-26));
49   
50   left = 39;
51   right = -76;
52   
53   result = left-right;
54   ASSERT(result == (39+76));
55
56   left = -12;
57   right = 56;
58   
59   result = left-right;
60   ASSERT(result == (-12-56));
61   
62   left = -39;
63   right = -20;
64   
65   result = left-right;
66   ASSERT(result == (-39+20));
67 }