]> git.eshelyaron.com Git - emacs.git/commitdiff
Add test for zerop
authorStefan Kangas <stefankangas@gmail.com>
Mon, 17 Feb 2025 01:21:26 +0000 (02:21 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:46:28 +0000 (09:46 +0100)
* test/lisp/subr-tests.el (subr-test-zerop): New test.

(cherry picked from commit f2fb19d008f57d83053e7981eecded6ace9ab6c7)

test/lisp/subr-tests.el

index 5b17c598efa85b0bdc690470f780f2732961c146..29767ed07b5ce441f2f629cd22f0e72ccdfea977 100644 (file)
 (require 'ert-x)
 (eval-when-compile (require 'cl-lib))
 
+(ert-deftest subr-test-zerop ()
+  (should (zerop 0))
+  (should (zerop 0.0))
+  (should (zerop -0))
+  (should (zerop -0.0))
+  (should-not (zerop -0.0e+NaN))
+  (should-not (zerop 0.0e+NaN))
+  (should-not (zerop float-pi))
+  (should-not (zerop 1.0e+INF))
+  (should-not (zerop (random most-positive-fixnum)))
+  (should-not (zerop (- (random (- most-negative-fixnum)))))
+  (should-not (zerop (1+ most-positive-fixnum)))
+  (should-not (zerop (1- most-negative-fixnum)))
+  (should-error (zerop "-5") :type 'wrong-type-argument))
+
 (ert-deftest let-when-compile ()
   ;; good case
   (should (equal (macroexpand '(let-when-compile ((foo (+ 2 3)))