* src/ds390/gen.c (genFarPointerSet),
[fw/sdcc] / support / regression / tests / shifts.c
index c709c5a2b76961a22b472f30f0d9552a34e13b13..0eb607f91a808f4cf007377efca0e50fc71baf35 100644 (file)
@@ -1,4 +1,5 @@
 /** Tests covering the shift operators.
+    disabled for pic16
 
     sign: signed, unsigned
     type: char, int, long
@@ -12,7 +13,7 @@
 #include <testfwk.h>
 
 void
-testShiftClasses(void)
+test1ShiftClasses(void)
 {
     {attr} {storage} {sign} {type} i, result;
 
@@ -30,7 +31,7 @@ testShiftClasses(void)
 }
 
 void
-testShiftRight(void)
+test2ShiftRight(void)
 {
     {attr} {storage} {type} i, result;
 
@@ -48,8 +49,8 @@ testShiftRight(void)
     ASSERT(result == -15); 
 }
 
-static void
-testShiftByteMultiples(void)
+void
+test3ShiftByteMultiples(void)
 {
     {attr} {storage} {type} i;
 
@@ -59,13 +60,13 @@ testShiftByteMultiples(void)
     ASSERT(i>>24 == ({type})({vals} >> 24));
 
     i = ({type}){vals};
-    ASSERT(({type})(i<<8)  == ({type})({vals} << 8));;
-    ASSERT(({type})(i<<16) == ({type})({vals} << 16));
-    ASSERT(({type})(i<<24) == ({type})({vals} << 24));
+    ASSERT( ({type})(i<<8)  ==  ({type})({vals} << 8));;
+    ASSERT((({type}) i<<16) == (({type}) {vals} << 16));
+    ASSERT((({type}) i<<24) == (({type}) {vals} << 24));
 }
 
-static void
-testShiftOne(void)
+void
+test4ShiftOne(void)
 {
     {attr} {storage} {sign} {type} i;
     {sign} {type} result;
@@ -86,3 +87,24 @@ testShiftOne(void)
     result <<= 1;
     ASSERT(result == ({type})(({type}){vals} << 1));
 }
+
+static {type} ShiftLeftByParam ({type} count)
+{
+    {attr} {storage} {type} i;
+    i = ({type}){vals};
+    return (i << count);
+}
+
+static {type} ShiftRightByParam ({type} count)
+{
+    {attr} {storage} {type} i;
+    i = ({type}){vals};
+    return (i >> count);
+}
+
+void
+testShiftByParam(void)
+{
+    ASSERT(ShiftLeftByParam(2)  == ({type})({vals} << 2));
+    ASSERT(ShiftRightByParam(2) == ({type})({vals} >> 2));
+}