aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Kangas2021-10-20 20:03:34 +0200
committerStefan Kangas2021-10-20 20:54:29 +0200
commit4e9764e6a155aa403d69d38fa06f4a774140f63c (patch)
tree33aaf44270da212572718d75c6e3ef63bbbc1b27 /test/src
parent5f5189e9be6c70c4db99e8057287d16955b9c620 (diff)
downloademacs-4e9764e6a155aa403d69d38fa06f4a774140f63c.tar.gz
emacs-4e9764e6a155aa403d69d38fa06f4a774140f63c.zip
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.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/floatfns-tests.el62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el
index 47fa1941626..a066d2e15e2 100644
--- a/test/src/floatfns-tests.el
+++ b/test/src/floatfns-tests.el
@@ -21,6 +21,68 @@
21 21
22(require 'ert) 22(require 'ert)
23 23
24(ert-deftest floatfns-tests-cos ()
25 (should (= (cos 0) 1.0))
26 (should (= (cos float-pi) -1.0)))
27
28(ert-deftest floatfns-tests-sin ()
29 (should (= (sin 0) 0.0)))
30
31(ert-deftest floatfns-tests-tan ()
32 (should (= (tan 0) 0.0)))
33
34(ert-deftest floatfns-tests-isnan ()
35 (should (isnan 0.0e+NaN))
36 (should (isnan -0.0e+NaN))
37 (should-error (isnan "foo") :type 'wrong-type-argument))
38
39(ert-deftest floatfns-tests-exp ()
40 (should (= (exp 0) 1.0)))
41
42(ert-deftest floatfns-tests-expt ()
43 (should (= (expt 2 8) 256)))
44
45(ert-deftest floatfns-tests-log ()
46 (should (= (log 1000 10) 3.0)))
47
48(ert-deftest floatfns-tests-sqrt ()
49 (should (= (sqrt 25) 5)))
50
51(ert-deftest floatfns-tests-abs ()
52 (should (= (abs 10) 10))
53 (should (= (abs -10) 10)))
54
55(ert-deftest floatfns-tests-logb ()
56 (should (= (logb 10000) 13)))
57
58(ert-deftest floatfns-tests-ceiling ()
59 (should (= (ceiling 0.5) 1)))
60
61(ert-deftest floatfns-tests-floor ()
62 (should (= (floor 1.5) 1)))
63
64(ert-deftest floatfns-tests-round ()
65 (should (= (round 1.49999999999) 1))
66 (should (= (round 1.50000000000) 2))
67 (should (= (round 1.50000000001) 2)))
68
69(ert-deftest floatfns-tests-truncate ()
70 (should (= (truncate float-pi) 3)))
71
72(ert-deftest floatfns-tests-fceiling ()
73 (should (= (fceiling 0.5) 1.0)))
74
75(ert-deftest floatfns-tests-ffloor ()
76 (should (= (ffloor 1.5) 1.0)))
77
78(ert-deftest floatfns-tests-fround ()
79 (should (= (fround 1.49999999999) 1.0))
80 (should (= (fround 1.50000000000) 2.0))
81 (should (= (fround 1.50000000001) 2.0)))
82
83(ert-deftest floatfns-tests-ftruncate ()
84 (should (= (ftruncate float-pi) 3.0)))
85
24(ert-deftest divide-extreme-sign () 86(ert-deftest divide-extreme-sign ()
25 (should (= (ceiling most-negative-fixnum -1.0) (- most-negative-fixnum))) 87 (should (= (ceiling most-negative-fixnum -1.0) (- most-negative-fixnum)))
26 (should (= (floor most-negative-fixnum -1.0) (- most-negative-fixnum))) 88 (should (= (floor most-negative-fixnum -1.0) (- most-negative-fixnum)))