1 (in-package #:strictmath-test)
5 ; This really is just here to check against regressions
6 (defun run-all-tests ()
8 ((results (mapcar #'funcall (reverse *tests*))))
9 (every #'identity results)))
11 (defun slurp-file (filename &key (element-type 'character) (sequence-type 'string))
12 (with-open-file (str filename :element-type element-type)
13 (let ((seq (make-sequence sequence-type (file-length str)))) (read-sequence seq str) seq)))
15 (defmacro deftest (name f)
22 (error (e) (format t "Got unexpected error in tests: ~A" e)))))
24 (format t "~c[1;32m- ~A passed~c[0m~%" #\Esc ,name #\Esc)
25 (format t "~c[1;31m- ~A failed~c[0m~%" #\Esc ,name #\Esc))
36 (destructuring-bind (deg expected-rad) pair
38 (= (strictmath:to-radians deg) expected-rad)
39 (format t "** Expected ~A but got ~A for ~A? **~%" expected-rad (strictmath:to-radians deg) deg))))
40 (with-open-file (str "resources/strictmath/testfiles/toRadiansData" :direction :input) (read str))))))
49 (destructuring-bind (deg expected-sin) pair
51 (= (strictmath:sin (strictmath:to-radians deg)) expected-sin)
52 (format t "** Expected ~A but got ~A for ~A? **~%"
54 (strictmath:sin (strictmath:to-radians deg))
56 (with-open-file (str "resources/strictmath/testfiles/sinData" :direction :input) (read str))))))
65 (destructuring-bind (deg expected-cos) pair
67 (= (strictmath:cos (strictmath:to-radians deg)) expected-cos)
68 (format t "** Expected ~A but got ~A for ~A? **~%"
70 (strictmath:cos (strictmath:to-radians deg))
72 (with-open-file (str "resources/strictmath/testfiles/cosData" :direction :input) (read str))))))