diff options
| author | Stefan Kangas | 2021-10-20 03:23:28 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2021-10-20 03:31:01 +0200 |
| commit | 62591c164cd6d0b0555e11b160ffa81bd3bb010f (patch) | |
| tree | c85eea63127165eb7b52a747bdfcc8d804ca941f /test/src/fns-tests.el | |
| parent | a4a35305101f24279d02d620a51b94b3e4682435 (diff) | |
| download | emacs-62591c164cd6d0b0555e11b160ffa81bd3bb010f.tar.gz emacs-62591c164cd6d0b0555e11b160ffa81bd3bb010f.zip | |
Add some tests for fns.c
* test/src/fns-tests.el (fns-tests-identity, fns-tests-random)
(fns-tests-length, fns-tests-safe-length)
(fns-tests-string-bytes): New tests.
Diffstat (limited to 'test/src/fns-tests.el')
| -rw-r--r-- | test/src/fns-tests.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 2d641cc3111..3dc2e7b3ec8 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -23,6 +23,29 @@ | |||
| 23 | 23 | ||
| 24 | (require 'cl-lib) | 24 | (require 'cl-lib) |
| 25 | 25 | ||
| 26 | (ert-deftest fns-tests-identity () | ||
| 27 | (let ((num 12345)) (should (eq (identity num) num))) | ||
| 28 | (let ((str "foo")) (should (eq (identity str) str))) | ||
| 29 | (let ((lst '(11))) (should (eq (identity lst) lst)))) | ||
| 30 | |||
| 31 | (ert-deftest fns-tests-random () | ||
| 32 | (should (integerp (random))) | ||
| 33 | (should (>= (random 10) 0)) | ||
| 34 | (should (< (random 10) 10))) | ||
| 35 | |||
| 36 | (ert-deftest fns-tests-length () | ||
| 37 | (should (= (length nil) 0)) | ||
| 38 | (should (= (length '(1 2 3)) 3)) | ||
| 39 | (should (= (length '[1 2 3]) 3)) | ||
| 40 | (should (= (length "foo") 3)) | ||
| 41 | (should-error (length t))) | ||
| 42 | |||
| 43 | (ert-deftest fns-tests-safe-length () | ||
| 44 | (should (= (safe-length '(1 2 3)) 3))) | ||
| 45 | |||
| 46 | (ert-deftest fns-tests-string-bytes () | ||
| 47 | (should (= (string-bytes "abc") 3))) | ||
| 48 | |||
| 26 | ;; Test that equality predicates work correctly on NaNs when combined | 49 | ;; Test that equality predicates work correctly on NaNs when combined |
| 27 | ;; with hash tables based on those predicates. This was not the case | 50 | ;; with hash tables based on those predicates. This was not the case |
| 28 | ;; for eql in Emacs 26. | 51 | ;; for eql in Emacs 26. |