]> git.sur5r.net Git - cc65/commitdiff
Made div-test.c use doesclrscrafterexit().
authorGreg King <gregdk@users.sf.net>
Fri, 9 Nov 2018 22:11:03 +0000 (17:11 -0500)
committerGreg King <gregdk@users.sf.net>
Fri, 9 Nov 2018 22:11:03 +0000 (17:11 -0500)
It no longer waits for a key tap if it doesn't need to do that.

Also, normalized the source code formatting.

testcode/lib/div-test.c

index 2d5c2541e26f539681bfe3d7f349d47126f578f1..401f13ff87e710e63838be994a37ba89df084faa 100644 (file)
@@ -2,37 +2,44 @@
 **
 ** This program tests the division and modulo operators
 ** and the div() library function.
-**
-** 2002-10-24, Greg King
 */
 
+#include <cc65.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdbool.h>
 
-static bool test(int dividend, int divisor) {
-        div_t result;
-
-        result = div(dividend, divisor);
-        printf("%+d/%+d= %+d, %+d%%%+d= %+d, div()= %+d, %+d\n",
-                dividend, divisor, dividend / divisor,
-                dividend, divisor, dividend % divisor,
-                result.quot, result.rem);
-        return result.quot * divisor + result.rem != dividend;
-        }
-
-int main(void) {
-        bool t;
-
-        printf("\nTest of division and modulus operations:\n\n");
-        t =     test(+40, +3) ||
-                test(+40, -3) ||
-                test(-40, +3) ||
-                test(-40, -3);
-        if (t)
-                printf("\nThe div() function made a wrong result!\n");
-
-        printf("\nTap a key, to exit. ");
-        getchar();
-        return (int)t;
-        }
+static bool test (int dividend, int divisor)
+{
+    div_t result;
+
+    result = div (dividend, divisor);
+    printf ("%+d/%+d= %+d, %+d%%%+d= %+d, div()= %+d, %+d\n",
+            dividend, divisor, dividend / divisor,
+            dividend, divisor, dividend % divisor,
+            result.quot, result.rem);
+
+    return result.quot * divisor + result.rem != dividend;
+}
+
+int main (void)
+{
+    bool t;
+
+    printf ("\nTest of division and modulus operations:\n\n");
+
+    t = test (+40, +3) ||
+        test (+40, -3) ||
+        test (-40, +3) ||
+        test (-40, -3);
+    if (t) {
+        printf ("\nThe div() function made a wrong result!\n");
+    }
+
+    if (doesclrscrafterexit ()) {
+        printf ("\nTap the Return key to quit. ");
+        getchar ();
+    }
+
+    return (int)t;
+}