794b729ea69b00ea371220c6f532af8f2d4351bd
[fw/sdcc] / support / regression / tests / staticinit.c
1 /** Tests that the static initialiser code works.
2     As the init code is now clever we have to be careful.
3
4     type: char, int, long
5 */
6 #include <testfwk.h>
7
8 static {type} smallDense[] = {
9     1, 2, 3, 4, 5, 6
10 };
11
12 static void
13 testSmallDense(void)
14 {
15     ASSERT(smallDense[0] == 1);
16     ASSERT(smallDense[1] == 2);
17     ASSERT(smallDense[2] == 3);
18     ASSERT(smallDense[3] == 4);
19     ASSERT(smallDense[4] == 5);
20     ASSERT(smallDense[5] == 6);
21 }
22
23 static {type} smallSparse[] = {
24     1, 1, 1, 1, 1, 1, 1, 1, 1
25 };
26
27 static void
28 testSmallSparse(void)
29 {
30     ASSERT(smallSparse[0] == 1);
31     ASSERT(smallSparse[1] == 1);
32     ASSERT(smallSparse[2] == 1);
33     ASSERT(smallSparse[3] == 1);
34     ASSERT(smallSparse[4] == 1);
35     ASSERT(smallSparse[5] == 1);
36     ASSERT(smallSparse[6] == 1);
37     ASSERT(smallSparse[7] == 1);
38     ASSERT(smallSparse[8] == 1);
39 }
40
41 static {type} smallSparseZero[] = {
42     0, 0, 0, 0, 0, 0, 0, 0, 0
43 };
44