Applied patch #2762516
[fw/sdcc] / src / regression / add2.c
index 020ed2d3f9a1adda6e1e2d35d8ba5e80f722ebf0..f9536e4db1fe584e4cd3b032246de6bd5e4bb23f 100644 (file)
@@ -1,14 +1,13 @@
+#include "gpsim_assert.h"
 
 // Addition tests - mostly int's
 
 /* bit types are not ANSI - so provide a way of disabling bit types
  * if this file is used to test other compilers besides SDCC */
-#define SUPPORT_BIT_TYPES 1
+#define SUPPORT_BIT_TYPES 0
 
 
-unsigned char success=0;
 unsigned char failures=0;
-unsigned char dummy=0;
 
 
 unsigned int aint0 = 0;
@@ -39,11 +38,11 @@ bit bit11 = 0;
 #endif
 
 
-void done()
+void
+done()
 {
-
-  dummy++;
-
+  ASSERT(MANGLE(failures) == 0);
+  PASSED();
 }
 
 void add_lit2uint(void)
@@ -104,17 +103,34 @@ void add_uint2uint2(void)
     failures++;
 
   aint1 += aint0;
-  if(aint1 != 39)
+  if(aint1 != 0x27)
     failures++;
 
   aint2 = aint1 + aint0;
-  if(aint2 != 46)
+  if(aint2 != 0x2e)
     failures++;
 
   aint3 = aint2 + aint1 + aint0;
-  if(aint3 != 92)
+  if(aint3 != 0x5c)
     failures++;
 
+  aint3 += 0xa0;
+  if(aint3 != 0xfc)
+    failures++;
+
+  aint3 += aint0;
+  if(aint3 != 0x103)
+    failures++;
+
+  aint1 += 0xffc0;
+  if(aint1 != 0xffe7)
+    failures++;
+
+  aint3 = aint2 + aint1 + aint0;
+  if(aint3 != 0x1c)
+    failures++;
+
+
 }
 
 #if SUPPORT_BIT_TYPES
@@ -144,6 +160,7 @@ void add_bits(void)
 
 /* add_bit2uchar(void) - assumes bit0 = 1, aint0 = 7  */
 
+#if SUPPORT_BIT_TYPES
 void add_bit2uchar(void)
 {
 
@@ -168,6 +185,7 @@ void add_bit2uint(void)
     failures++;
 
 }
+#endif
 
 /***********************************/
 
@@ -282,23 +300,27 @@ void main(void)
 
   aint0=16;
   aint1=0;
-  //  add_uint2uint();
+  add_uint2uint();
 
 
   aint0 = 0;
   aint1 = 32;
-  //  add_uint2uint2();
+  aint2 = 0;
+  add_uint2uint2();
 
 #if SUPPORT_BIT_TYPES
-  //  add_bits();
+  add_bits();
+
+  achar0 = 7;
+  add_bit2uchar();
 
-  //  add_bit2uchar();
-  //  add_bit2uint();
+  aint0 = 0;
+  bit0 = 1;
+  add_bit2uint();
 #endif
 
   aint0 = 0;
   addlits();
 
-  success = failures;
   done();
 }