;;;; fx-utils-test -*- Scheme -*- ;;;; Kon Lovett, Jul '18 (import test) (test-begin "Fx Utils") ;;; (import (chicken base)) (import (chicken fixnum)) ;; (import fx-inlines) (test-group "Fx Inlines" (test-assert (fxzero? 0)) (test-assert (not (fxzero? 1))) (test-assert (not (fxzero? most-positive-fixnum))) (test-assert (not (fxzero? most-negative-fixnum))) (test-assert (not (fxpositive? 0))) (test-assert (not (fxpositive? most-negative-fixnum))) (test-assert (fxpositive? most-positive-fixnum)) (test-assert (fxnatural? 0)) (test-assert (not (fxnatural? most-negative-fixnum))) (test-assert (fxnatural? most-positive-fixnum)) (test-assert (not (fxnegative? 0))) (test-assert (fxnegative? most-negative-fixnum)) (test-assert (not (fxnegative? most-positive-fixnum))) (test 4 (fxadd1 3)) (test 2 (fxsub1 3)) (test 27 (fxcub 3)) ) ;; (import fx-utils) (test-group "Fx Utils" (test-assert (fixnum? (fxrandom))) (test-assert (fixnum? (fxrandom 2456))) (test -1 (fxlog2 0)) (test 0 (fxlog2 1)) (test 1 (fxlog2 2)) (test 1 (fxlog2 3)) (test 2 (fxlog2 4)) (test -1 (fxpow2log2 0)) (test 4 (fxpow2log2 3)) (test 8 (fxpow2log2 7)) (test 16 (fxpow2log2 15)) (test 16 (fxpow2log2 16)) (test 32 (fxpow2log2 17)) (test 16 (fxdistance 1 1 5 5)) (receive (mx mn) (fxmax-and-min 1 -1 -16 13 2 16 7 -8) (test "fxmax-and-min max" 16 mx) (test "fxmax-and-min min" -16 mn) ) (receive (q m) (fxquo-and-mod 1 2) (test "fxquo-and-mod q" 0 q) (test "fxquo-and-mod m" 1 m) ) ) ;;; (test-end "Fx Utils") (test-exit)