Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/lib/libc/div Add regression tests for div/ldiv/lldiv.



details:   https://anonhg.NetBSD.org/src/rev/a64620fc7748
branches:  trunk
changeset: 501822:a64620fc7748
user:      simonb <simonb%NetBSD.org@localhost>
date:      Mon Jan 08 04:39:31 2001 +0000

description:
Add regression tests for div/ldiv/lldiv.

Inspired by port-i386/11914 from Luke Mewburn.

diffstat:

 regress/lib/libc/div/Makefile |  10 ++++++++++
 regress/lib/libc/div/div.c    |  41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)

diffs (59 lines):

diff -r f337c80121e5 -r a64620fc7748 regress/lib/libc/div/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/div/Makefile     Mon Jan 08 04:39:31 2001 +0000
@@ -0,0 +1,10 @@
+#      $NetBSD: Makefile,v 1.1 2001/01/08 04:39:31 simonb Exp $
+
+PROG=  div
+NOMAN= noman, no way, man
+WARNS?=        1
+
+regress: ${PROG}
+       ./${PROG}
+
+.include <bsd.prog.mk>
diff -r f337c80121e5 -r a64620fc7748 regress/lib/libc/div/div.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/div/div.c        Mon Jan 08 04:39:31 2001 +0000
@@ -0,0 +1,41 @@
+/*     $NetBSD: div.c,v 1.1 2001/01/08 04:39:31 simonb Exp $   */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define        NUM     1999236
+#define        DENOM   1000000
+#define        QUOT    1
+#define        REM     999236
+
+int
+main(void)
+{
+       div_t d;
+       ldiv_t ld;
+       lldiv_t lld;
+       int error = 0;
+
+       d = div(NUM, DENOM);
+       ld = ldiv(NUM, DENOM);
+       lld = lldiv(NUM, DENOM);
+
+       if (d.quot != QUOT || d.rem != REM) {
+               fprintf(stderr, "div returned (%d, %d), expected (%d, %d)\n",
+                   d.quot, d.rem, QUOT, REM);
+               error++;
+       }
+       if (ld.quot != QUOT || ld.rem != REM) {
+               fprintf(stderr, "ldiv returned (%ld, %ld), expected (%d, %d)\n",
+                   ld.quot, ld.rem, QUOT, REM);
+               error++;
+       }
+       if (lld.quot != QUOT || lld.rem != REM) {
+               fprintf(stderr, "lldiv returned (%lld, %lld), expected (%d, %d)\n",
+                   lld.quot, lld.rem, QUOT, REM);
+               error++;
+       }
+       if (error > 0)
+               fprintf(stderr, "div: got %d errors\n", error);
+       exit(error);
+}



Home | Main Index | Thread Index | Old Index