Add some tests for floatfns.c
* test/src/floatfns-tests.el (floatfns-tests-cos) (floatfns-tests-sin, floatfns-tests-tan, floatfns-tests-isnan) (floatfns-tests-exp, floatfns-tests-expt, floatfns-tests-log) (floatfns-tests-sqrt, floatfns-tests-abs, floatfns-tests-logb) (floatfns-tests-ceiling, floatfns-tests-floor) (floatfns-tests-round, floatfns-tests-truncate) (floatfns-tests-fceiling, floatfns-tests-ffloor) (floatfns-tests-fround, floatfns-tests-ftruncate) (divide-extreme-sign): New tests.
This commit is contained in:
parent
5f5189e9be
commit
4e9764e6a1
1 changed files with 62 additions and 0 deletions
|
@ -21,6 +21,68 @@
|
|||
|
||||
(require 'ert)
|
||||
|
||||
(ert-deftest floatfns-tests-cos ()
|
||||
(should (= (cos 0) 1.0))
|
||||
(should (= (cos float-pi) -1.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-sin ()
|
||||
(should (= (sin 0) 0.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-tan ()
|
||||
(should (= (tan 0) 0.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-isnan ()
|
||||
(should (isnan 0.0e+NaN))
|
||||
(should (isnan -0.0e+NaN))
|
||||
(should-error (isnan "foo") :type 'wrong-type-argument))
|
||||
|
||||
(ert-deftest floatfns-tests-exp ()
|
||||
(should (= (exp 0) 1.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-expt ()
|
||||
(should (= (expt 2 8) 256)))
|
||||
|
||||
(ert-deftest floatfns-tests-log ()
|
||||
(should (= (log 1000 10) 3.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-sqrt ()
|
||||
(should (= (sqrt 25) 5)))
|
||||
|
||||
(ert-deftest floatfns-tests-abs ()
|
||||
(should (= (abs 10) 10))
|
||||
(should (= (abs -10) 10)))
|
||||
|
||||
(ert-deftest floatfns-tests-logb ()
|
||||
(should (= (logb 10000) 13)))
|
||||
|
||||
(ert-deftest floatfns-tests-ceiling ()
|
||||
(should (= (ceiling 0.5) 1)))
|
||||
|
||||
(ert-deftest floatfns-tests-floor ()
|
||||
(should (= (floor 1.5) 1)))
|
||||
|
||||
(ert-deftest floatfns-tests-round ()
|
||||
(should (= (round 1.49999999999) 1))
|
||||
(should (= (round 1.50000000000) 2))
|
||||
(should (= (round 1.50000000001) 2)))
|
||||
|
||||
(ert-deftest floatfns-tests-truncate ()
|
||||
(should (= (truncate float-pi) 3)))
|
||||
|
||||
(ert-deftest floatfns-tests-fceiling ()
|
||||
(should (= (fceiling 0.5) 1.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-ffloor ()
|
||||
(should (= (ffloor 1.5) 1.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-fround ()
|
||||
(should (= (fround 1.49999999999) 1.0))
|
||||
(should (= (fround 1.50000000000) 2.0))
|
||||
(should (= (fround 1.50000000001) 2.0)))
|
||||
|
||||
(ert-deftest floatfns-tests-ftruncate ()
|
||||
(should (= (ftruncate float-pi) 3.0)))
|
||||
|
||||
(ert-deftest divide-extreme-sign ()
|
||||
(should (= (ceiling most-negative-fixnum -1.0) (- most-negative-fixnum)))
|
||||
(should (= (floor most-negative-fixnum -1.0) (- most-negative-fixnum)))
|
||||
|
|
Loading…
Add table
Reference in a new issue