Added simple static array init test
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 25 Aug 2001 03:51:00 +0000 (03:51 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 25 Aug 2001 03:51:00 +0000 (03:51 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1168 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/regression/tests/staticinit.c [new file with mode: 0644]

diff --git a/support/regression/tests/staticinit.c b/support/regression/tests/staticinit.c
new file mode 100644 (file)
index 0000000..794b729
--- /dev/null
@@ -0,0 +1,44 @@
+/** Tests that the static initialiser code works.
+    As the init code is now clever we have to be careful.
+
+    type: char, int, long
+*/
+#include <testfwk.h>
+
+static {type} smallDense[] = {
+    1, 2, 3, 4, 5, 6
+};
+
+static void
+testSmallDense(void)
+{
+    ASSERT(smallDense[0] == 1);
+    ASSERT(smallDense[1] == 2);
+    ASSERT(smallDense[2] == 3);
+    ASSERT(smallDense[3] == 4);
+    ASSERT(smallDense[4] == 5);
+    ASSERT(smallDense[5] == 6);
+}
+
+static {type} smallSparse[] = {
+    1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+static void
+testSmallSparse(void)
+{
+    ASSERT(smallSparse[0] == 1);
+    ASSERT(smallSparse[1] == 1);
+    ASSERT(smallSparse[2] == 1);
+    ASSERT(smallSparse[3] == 1);
+    ASSERT(smallSparse[4] == 1);
+    ASSERT(smallSparse[5] == 1);
+    ASSERT(smallSparse[6] == 1);
+    ASSERT(smallSparse[7] == 1);
+    ASSERT(smallSparse[8] == 1);
+}
+
+static {type} smallSparseZero[] = {
+    0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+