0060b8b0a585b03c721d340b0a728ad23bd1e938
[fw/sdcc] / support / regression / tests / nullstring.c
1 /** Null character in string tests.
2
3      storage: data, xdata, code,
4 */
5 #include <testfwk.h>
6
7 {storage} char string1[] = "";
8 {storage} char string2[] = "a\0b\0c";
9 {storage} char string3[5] = "a\0b\0c";
10
11 void
12 testStringArray(void)
13 {
14   /* Make sure the strings are the correct size */
15   /* and have the terminating null character */
16   ASSERT(sizeof(string1)==1);
17   ASSERT(sizeof(string2)==6);
18   ASSERT(sizeof(string3)==5);
19   ASSERT(string1[0]==0);
20   ASSERT(string2[5]==0);
21
22   ASSERT(string2[0]=='a');
23   ASSERT(string2[2]=='b');
24   ASSERT(string2[4]=='c');
25
26 }
27
28 void
29 testStringConst(void)
30 {
31   char * constStr1 = "";
32   char * constStr2 = "a\0b\0c";
33
34   ASSERT (constStr1[0]==0);
35   ASSERT (constStr2[5]==0);
36 }