* src/SDCCast.c (createIvalCharPtr),
[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 #if defined(PORT_HOST) || defined(SDCC_z80) || defined(SDCC_gbz80)
8 # define data
9 # define xdata
10 # define code
11 #endif
12
13 {storage} char string1[] = "";
14 {storage} char string2[] = "a\0b\0c";
15 {storage} char string3[5] = "a\0b\0c";
16
17 void
18 testStringArray(void)
19 {
20   /* Make sure the strings are the correct size */
21   /* and have the terminating null character */
22   ASSERT(sizeof(string1)==1);
23   ASSERT(sizeof(string2)==6);
24   ASSERT(sizeof(string3)==5);
25   ASSERT(string1[0]==0);
26   ASSERT(string2[5]==0);
27   
28   ASSERT(string2[0]=='a');
29   ASSERT(string2[2]=='b');
30   ASSERT(string2[4]=='c');  
31   
32 }
33
34 void
35 testStringConst(void)
36 {
37   char * constStr1 = "";
38   char * constStr2 = "a\0b\0c";
39
40   ASSERT (constStr1[0]==0);
41   ASSERT (constStr2[5]==0);
42 }