]> git.gag.com Git - fw/sdcc/blobdiff - support/regression/tests/shifts.c
Updated most tests to also do longs
[fw/sdcc] / support / regression / tests / shifts.c
index 60b6633246f79e460ff184d380f45f38f8b161ec..23a594d051682901dbd6793093d2601c90137f24 100644 (file)
@@ -1,6 +1,7 @@
 /** Tests covering the shift operators.
 
-    type: char, int
+    sign: signed, unsigned
+    type: char, int, long
     storage: static, 
     attr: volatile
 
 */
 #include <testfwk.h>
 
-static void
+void
 testShiftClasses(void)
 {
-    {attr} {storage} {type} i, result;
+    {attr} {storage} {sign} {type} i, result;
 
-    i = 50;
-    ASSERT(i>>3 == 6);
-    ASSERT(i<<2 == 200);
+    i = 30;
+    ASSERT(i>>3 == 3);
+    ASSERT(i<<2 == 120);
     
     result = i;
     result >>= 2;
-    ASSERT(result == 12);
+    ASSERT(result == 7);
 
     result = i;
     result <<= 2;
-    ASSERT(result == 200);
+    ASSERT(result == 120);
+}
+
+void
+testShiftRight(void)
+{
+    {attr} {storage} {type} i, result;
+
+    i = -120;
+    ASSERT(i>>2 == -30);
+
+    result = i;
+    result >>= 3;
+    ASSERT(result == -15); 
 }
 
 /** PENDING: Disabled. */
@@ -33,6 +47,7 @@ static void
 testShiftByteMultiples(void)
 {
 #if 0
+    /* PENDING */
     {attr} {storage} {type} i;
 
     i = ({type}){vals};
@@ -41,7 +56,7 @@ testShiftByteMultiples(void)
     ASSERT(i>>24 == (({type}){vals} >> 24));
 
     i = ({type}){vals};
-    ASSERT(i<<8 == (({type}){vals} << 8));
+    ASSERT(i<<8  == (({type}){vals} << 8));;
     ASSERT(i<<16 == (({type}){vals} << 16));
     ASSERT(i<<24 == (({type}){vals} << 24));
 #endif
@@ -50,8 +65,8 @@ testShiftByteMultiples(void)
 static void
 testShiftOne(void)
 {
-    {attr} {storage} {type} i;
-    {type} result;
+    {attr} {storage} {sign} {type} i;
+    {sign} {type} result;
 
     i = ({type}){vals};