summaryrefslogtreecommitdiff
path: root/support/regression/tests/nullstring.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /support/regression/tests/nullstring.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'support/regression/tests/nullstring.c')
-rw-r--r--support/regression/tests/nullstring.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/support/regression/tests/nullstring.c b/support/regression/tests/nullstring.c
new file mode 100644
index 0000000..bf9d85f
--- /dev/null
+++ b/support/regression/tests/nullstring.c
@@ -0,0 +1,45 @@
+/** Null character in string tests.
+
+ storage: __data, __xdata, __code,
+*/
+#include <testfwk.h>
+
+#ifndef PORT_HOST
+#pragma disable_warning 147 //no warning about excess elements in array of chars initializer
+#endif
+
+{storage} char string1[] = "";
+{storage} char string2[] = "a\0b\0c";
+{storage} char string3[5] = "a\0b\0c";
+
+void
+testStringArray (void)
+{
+ /* Make sure the strings are the correct size */
+ /* and have the terminating null character */
+ ASSERT (sizeof (string1) == 1);
+ ASSERT (sizeof (string2) == 6);
+ ASSERT (sizeof (string3) == 5);
+ ASSERT (string1[0] == 0);
+ ASSERT (string2[5] == 0);
+
+ ASSERT (string2[0]== 'a');
+ ASSERT (string2[2]== 'b');
+ ASSERT (string2[4]== 'c');
+
+}
+
+void
+testStringConst (void)
+{
+ const char * constStr1 = "";
+ const char * constStr2 = "a\0b\0c";
+
+ ASSERT (constStr1[0] == 0);
+ ASSERT (constStr2[0] == 'a');
+ ASSERT (constStr2[1] == 0);
+ ASSERT (constStr2[2] == 'b');
+ ASSERT (constStr2[3] == 0);
+ ASSERT (constStr2[4] == 'c');
+ ASSERT (constStr2[5] == 0);
+}