diff options
| author | Stefan Kangas | 2022-10-16 08:23:35 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2022-10-16 08:23:55 +0200 |
| commit | c4c4a60f71254b7f59010c5539545fc2fc49b855 (patch) | |
| tree | 343455e48ff616bf1919e3ea228eda871fbefcb8 /test/src | |
| parent | cf19743aca5cb68c65bf5c8c3730a2eae3cb21e8 (diff) | |
| download | emacs-c4c4a60f71254b7f59010c5539545fc2fc49b855.tar.gz emacs-c4c4a60f71254b7f59010c5539545fc2fc49b855.zip | |
Expand 'random' testsuite
* test/src/fns-tests.el (ert): Require.
(fns-tests-random): Expand test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/fns-tests.el | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 5d5d497c997..fde5af38fc8 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'cl-lib) | 24 | (require 'cl-lib) |
| 25 | (require 'ert) | ||
| 25 | 26 | ||
| 26 | (ert-deftest fns-tests-identity () | 27 | (ert-deftest fns-tests-identity () |
| 27 | (let ((num 12345)) (should (eq (identity num) num))) | 28 | (let ((num 12345)) (should (eq (identity num) num))) |
| @@ -29,9 +30,22 @@ | |||
| 29 | (let ((lst '(11))) (should (eq (identity lst) lst)))) | 30 | (let ((lst '(11))) (should (eq (identity lst) lst)))) |
| 30 | 31 | ||
| 31 | (ert-deftest fns-tests-random () | 32 | (ert-deftest fns-tests-random () |
| 32 | (should (integerp (random))) | 33 | (unwind-protect |
| 33 | (should (>= (random 10) 0)) | 34 | (progn |
| 34 | (should (< (random 10) 10))) | 35 | (should-error (random -1) :type 'args-out-of-range) |
| 36 | (should-error (random 0) :type 'args-out-of-range) | ||
| 37 | (should (integerp (random))) | ||
| 38 | (should (= (random 1) 0)) | ||
| 39 | (should (>= (random 10) 0)) | ||
| 40 | (should (< (random 10) 10)) | ||
| 41 | (should (equal (random "seed") (random "seed"))) | ||
| 42 | ;; The probability of four calls being the same is low. | ||
| 43 | ;; This makes sure that the value isn't constant. | ||
| 44 | (should (not (= (random t) (random t) (random t) (random t)))) | ||
| 45 | ;; Handle bignums. | ||
| 46 | (should (integerp (random (1+ most-positive-fixnum))))) | ||
| 47 | ;; Reset the PRNG seed after testing. | ||
| 48 | (random t))) | ||
| 35 | 49 | ||
| 36 | (ert-deftest fns-tests-length () | 50 | (ert-deftest fns-tests-length () |
| 37 | (should (= (length nil) 0)) | 51 | (should (= (length nil) 0)) |