(library (tests fixnums) (export test-fxdiv-and-mod) (import (ikarus)) (define (test-fxdiv-and-mod) (define (test x1 x2) (let-values ([(d m) (fxdiv-and-mod x1 x2)]) (printf "(fxdiv-and-mod ~s ~s) = ~s ~s\n" x1 x2 d m) (assert (= d (fxdiv x1 x2))) (assert (= m (fxmod x1 x2))) (assert (<= 0 m)) (assert (< m (abs x2))) (assert (= x1 (+ (* d x2) m))))) (test +17 +3) (test +17 -3) (test -17 +3) (test -17 -3) (test +16 +3) (test +16 -3) (test -16 +3) (test -16 -3) (test +15 +3) (test +15 -3) (test -15 +3) (test -15 -3) (test +10 +4) (test +10 -4) (test -10 +4) (test -10 -4)))