]> git.eshelyaron.com Git - emacs.git/commitdiff
Add time-convert tests
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 6 Dec 2021 01:38:58 +0000 (17:38 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 6 Dec 2021 07:24:08 +0000 (23:24 -0800)
* test/src/timefns-tests.el (time-convert-forms): New test.

test/src/timefns-tests.el

index bba9b3fcd8c21e3bade88c66272b129ef155d838..f801478a9a13cee26edd01123c1527787a622a8d 100644 (file)
@@ -242,4 +242,16 @@ a fixed place on the right and are padded on the left."
           (should (= xdiv (float-time (time-convert xdiv t))))))
       (setq x (* x 2)))))
 
+(ert-deftest time-convert-forms ()
+  ;; These computations involve numbers that should have exact
+  ;; representations on any Emacs platform.
+  (dolist (time '(-86400 -1 0 1 86400))
+    (dolist (delta '(0 0.0 0.25 3.25 1000 1000.25))
+      (let ((time+ (+ time delta))
+           (time- (- time delta)))
+       (dolist (form '(nil t list 4 1000 1000000 1000000000))
+         (should (time-equal-p time (time-convert time form)))
+         (should (time-equal-p time- (time-convert time- form)))
+         (should (time-equal-p time+ (time-convert time+ form))))))))
+
 ;;; timefns-tests.el ends here