1 ; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3. See distributed LICENSE.txt.
2 (in-package #:strictmath-test)
6 ; This really is just here to check against regressions
7 (defun run-all-tests ()
9 ((results (mapcar #'funcall (reverse *tests*))))
10 (every #'identity results)))
12 (defun slurp-file (filename &key (element-type 'character) (sequence-type 'string))
13 (with-open-file (str filename :element-type element-type)
14 (let ((seq (make-sequence sequence-type (file-length str)))) (read-sequence seq str) seq)))
16 (defmacro deftest (name f)
23 (error (e) (format t "Got unexpected error in tests: ~A" e)))))
25 (format t "~c[1;32m- ~A passed~c[0m~%" #\Esc ,name #\Esc)
26 (format t "~c[1;31m- ~A failed~c[0m~%" #\Esc ,name #\Esc))
37 (destructuring-bind (deg expected-rad) pair
39 (= (strictmath:to-radians deg) expected-rad)
40 (format t "** Expected ~A but got ~A for ~A? **~%" expected-rad (strictmath:to-radians deg) deg))))
41 (with-open-file (str "resources/strictmath/testfiles/toRadiansData" :direction :input) (read str))))))
50 (destructuring-bind (deg expected-sin) pair
52 (= (strictmath:sin (strictmath:to-radians deg)) expected-sin)
53 (format t "** Expected ~A but got ~A for ~A? **~%"
55 (strictmath:sin (strictmath:to-radians deg))
57 (with-open-file (str "resources/strictmath/testfiles/sinData" :direction :input) (read str))))))
66 (destructuring-bind (deg expected-cos) pair
68 (= (strictmath:cos (strictmath:to-radians deg)) expected-cos)
69 (format t "** Expected ~A but got ~A for ~A? **~%"
71 (strictmath:cos (strictmath:to-radians deg))
73 (with-open-file (str "resources/strictmath/testfiles/cosData" :direction :input) (read str))))))