Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / storage.c
1 /** Tests many of the basic operators from each of the storage types to every other.
2
3     source_storage: static, register,
4     dest_storage: static, register, 
5     type: char, int, long
6  */
7 #include <testfwk.h>
8
9 /** Simple function that spoils sdcc's optimiser by hiding an assign.
10  */
11 {type}
12 spoilAssign({type} in)
13 {
14     return in;
15 }
16
17 void
18 testStorageTypes(void)
19 {
20     {source_storage} {type} source;
21     {dest_storage} {type} dest;
22
23     source = spoilAssign(17);
24     // Test compare against a const
25     ASSERT(source == 17);
26
27     dest = spoilAssign(126);
28     ASSERT(dest == 126);
29     ASSERT(dest != source);
30
31     // Test assignment
32     dest = source;
33     ASSERT(dest == source);
34
35     // Test cmp
36     dest--;
37     ASSERT(dest == 16);
38     ASSERT(dest < source);
39     
40     dest += 8;
41     ASSERT(dest == 24);
42     ASSERT(source < dest);
43 }