* src/pic/ralloc.c (debugLogRegType): Removed some old types to get it to compile.
[fw/sdcc] / support / regression / tests / muldiv.c
index 354501dc695f43be3e49e2de9474e9c48e63a356..dc8bd801e1f7dbe2da63c59ad00627f59a1280a0 100644 (file)
@@ -1,43 +1,83 @@
 /** Simple test for the mul/div/mod operations.
 
-    type: int, signed char, short
+    type: int, char, short, long
     storage: static,
     attr: volatile,
 */
 #include <testfwk.h>
 
-static void
+void
+testUnsignedModDiv(void)
+{
+    {attr} {storage} unsigned {type} i;
+    unsigned {type} result;
+
+    i = 100;
+
+    result = i/3;
+    ASSERT(result == 33);
+
+    result = i/12;
+    ASSERT(result == 8);
+
+    result = i%7;
+    ASSERT(result == 2);
+
+    result = i%34;
+    ASSERT(result == 32);
+}
+
+void
+testUnsignedMul(void)
+{
+    {attr} {storage} unsigned {type} i;
+    unsigned {type} result;
+
+    i = 37;
+
+    LOG(("i*3 == 111 = %u\n", i*3));
+    result = i*3;
+    ASSERT(result == 111);
+
+    result = i*12;
+    ASSERT(result == ((unsigned {type})444));
+}
+
+void
 testMul(void)
 {
-    {attr} {storage} {type} i;
-    {type} result;
+    {attr} {storage} signed {type} i;
+    signed {type} result;
 
     i = 5;
 
-    LOG(("i*5 == 25 = %u\n", (int)i*5));
+    LOG(("i*5 == 25 = %u\n", (int)(i*5)));
     result = i*5;
     ASSERT(result == 25);
-    LOG(("i*-4 == -20 = %u\n", (int)i*-4));
+    LOG(("i*-4 == -20 = %u\n", (int)(i*-4)));
     ASSERT(i*-4 == -20);
 
     i = -10;
-    LOG(("i*12 == -120 = %u\n", (int)i*12));
+    LOG(("i*12 == -120 = %u\n", (int)(i*12)));
     ASSERT(i*12 == -120);
-    LOG(("i*-3 == 30 = %u\n", (int)i*-3));
+    LOG(("i*-3 == 30 = %u\n", (int)(i*-3)));
     ASSERT(i*-3 == 30);
+}
 
-    LOG(("30 == %u\n", (int)i*-3));
+void mark(void)
+{
 }
 
-static void
+void
 testDiv(void)
 {
-    {attr} {storage} {type} i;
+    {attr} {storage} signed {type} i;
 
     i = 100;
     LOG(("i/5 == 20 = %u\n", (int)i/5));
     ASSERT(i/5 == 20);
     LOG(("i/-4 == -25 = %u\n", (int)i/-4));
+    mark();
     ASSERT(i/-4 == -25);
 
     i = -50;
@@ -47,10 +87,10 @@ testDiv(void)
     ASSERT(i/-12 == 4);
 }
 
-static void
+void
 testMod(void)
 {
-    {attr} {storage} {type} i;
+    {attr} {storage} signed {type} i;
 
     // Disabled the LOG functions due to a bug in sdcc involving
     // vaargs.