summaryrefslogtreecommitdiff
path: root/test/src/emacs-module-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/emacs-module-tests.el')
-rw-r--r--test/src/emacs-module-tests.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index 9eb38cd4548..173b63670fc 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -342,6 +342,25 @@ Interactively, you can try hitting \\[keyboard-quit] to quit."
(ert-info ((format "input: %s" input))
(should-error (mod-test-add-nanosecond input)))))
+(ert-deftest mod-test-nanoseconds ()
+ "Test truncation when converting to `struct timespec'."
+ (dolist (test-case '((0 . 0)
+ (-1 . -1000000000)
+ ((1 . 1000000000) . 1)
+ ((-1 . 1000000000) . -1)
+ ((1 . 1000000000000) . 0)
+ ((-1 . 1000000000000) . -1)
+ ((999 . 1000000000000) . 0)
+ ((-999 . 1000000000000) . -1)
+ ((1000 . 1000000000000) . 1)
+ ((-1000 . 1000000000000) . -1)
+ ((0 0 0 1) . 0)
+ ((0 0 0 -1) . -1)))
+ (let ((input (car test-case))
+ (expected (cdr test-case)))
+ (ert-info ((format "input: %S, expected result: %d" input expected))
+ (should (eq (mod-test-nanoseconds input) expected))))))
+
(ert-deftest mod-test-double ()
(dolist (input (list 0 1 2 -1 42 12345678901234567890
most-positive-fixnum (1+ most-positive-fixnum)