Created
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 30 Sep 2001 01:51:23 +0000 (01:51 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 30 Sep 2001 01:51:23 +0000 (01:51 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1328 4a8a32a2-be11-0410-ad9d-d568d2c75423

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

diff --git a/support/regression/tests/driverstruct.c b/support/regression/tests/driverstruct.c
new file mode 100644 (file)
index 0000000..f6219e6
--- /dev/null
@@ -0,0 +1,45 @@
+/** Tests a few features of a driver struct - a struct with
+    many function pointers.
+*/
+#include <testfwk.h>
+
+/* Set to one to show the bug */
+#if 0
+#define NAME(_a)       _a
+#else
+#define NAME(_a)
+#endif
+
+typedef unsigned char uchar;
+
+/* Originally from UZIX - http://uzix.sourceforge.net/
+ */
+
+typedef struct s_devsw {
+       uchar   minors;         /* # of minor device numbers */
+       int     (*dev_init)(uchar NAME(minor));
+       int     (*dev_open)(uchar NAME(minor));
+       int     (*dev_close)(uchar NAME(minor));
+       int     (*dev_read)(uchar NAME(minor), uchar NAME(w));
+       int     (*dev_write)(uchar NAME(minor), uchar NAME(w));
+       int     (*dev_ioctl)(uchar NAME(minor), int cmd, void *data);
+} devsw_t;
+
+static int
+_init(uchar minor)
+{
+  return minor;
+}
+
+static devsw_t _sillyDriver = {
+  1,
+  _init,
+  NULL, NULL, NULL, NULL, NULL
+};
+
+int
+initProxy(void)
+{
+  return (*_sillyDriver.dev_init)(5);
+}
+
diff --git a/support/regression/tests/enum.c b/support/regression/tests/enum.c
new file mode 100644 (file)
index 0000000..19e0fdb
--- /dev/null
@@ -0,0 +1,52 @@
+/* Test the types of enum.
+ */
+#include <testfwk.h>
+
+enum _SimpleEnum {
+  SIMPLE_ZERO,
+  SIMPLE_ONE,
+  SIMPLE_TWO
+};
+
+enum _ValuesEnum {
+  VALUES_ZERO,
+  VALUES_FIVE = 5,
+  VALUES_SIX,
+  VALUES_SEVEN,
+  VALUES_TWELVE = 12
+};
+
+enum _IndexedEnum {
+  INDEXED_ZERO,
+  INDEXED_ONE,
+  /* PENDING: Fails */
+  //INDEXED_ONE_ALIAS = INDEXED_ONE,
+  INDEXED_TWO
+};
+
+void
+testSimpleEnum(void)
+{
+  ASSERT(SIMPLE_ZERO == 0);
+  ASSERT(SIMPLE_ONE == 1);
+  ASSERT(SIMPLE_TWO == 2);
+}
+
+void 
+testValuesEnum(void)
+{
+  ASSERT(VALUES_ZERO == 0);
+  ASSERT(VALUES_FIVE == 5);
+  ASSERT(VALUES_SIX == 6);
+  ASSERT(VALUES_SEVEN == 7);
+  ASSERT(VALUES_TWELVE == 12);
+}
+
+void
+testIndexedEnum(void)
+{
+  ASSERT(INDEXED_ZERO == 0);
+  ASSERT(INDEXED_ONE == 1);
+  //  ASSERT(INDEXED_ONE_ALIAS == 1);
+  ASSERT(INDEXED_TWO == 2);
+}