Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / nullstring.c
1 /** Null character in string tests.
2
3      storage: data, xdata, code,
4 */
5 #include <testfwk.h>
6
7 #ifndef PORT_HOST
8 #pragma disable_warning 147 //no warning about excess elements in array of chars initializer
9 #endif
10
11 {storage} char string1[] = "";
12 {storage} char string2[] = "a\0b\0c";
13 {storage} char string3[5] = "a\0b\0c";
14
15 void
16 testStringArray (void)
17 {
18   /* Make sure the strings are the correct size */
19   /* and have the terminating null character */
20   ASSERT (sizeof (string1) == 1);
21   ASSERT (sizeof (string2) == 6);
22   ASSERT (sizeof (string3) == 5);
23   ASSERT (string1[0] == 0);
24   ASSERT (string2[5] == 0);
25
26   ASSERT (string2[0]== 'a');
27   ASSERT (string2[2]== 'b');
28   ASSERT (string2[4]== 'c');
29
30 }
31
32 void
33 testStringConst(void)
34 {
35   char * constStr1 = "";
36   char * constStr2 = "a\0b\0c";
37
38   ASSERT (constStr1[0] == 0);
39   ASSERT (constStr2[5] == 0);
40 }