From: Stefan Kangas Date: Wed, 20 Oct 2021 01:23:28 +0000 (+0200) Subject: Add some tests for fns.c X-Git-Tag: emacs-29.0.90~3671^2~486 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=62591c164cd6d0b0555e11b160ffa81bd3bb010f;p=emacs.git 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. --- 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 @@ (require 'cl-lib) +(ert-deftest fns-tests-identity () + (let ((num 12345)) (should (eq (identity num) num))) + (let ((str "foo")) (should (eq (identity str) str))) + (let ((lst '(11))) (should (eq (identity lst) lst)))) + +(ert-deftest fns-tests-random () + (should (integerp (random))) + (should (>= (random 10) 0)) + (should (< (random 10) 10))) + +(ert-deftest fns-tests-length () + (should (= (length nil) 0)) + (should (= (length '(1 2 3)) 3)) + (should (= (length '[1 2 3]) 3)) + (should (= (length "foo") 3)) + (should-error (length t))) + +(ert-deftest fns-tests-safe-length () + (should (= (safe-length '(1 2 3)) 3))) + +(ert-deftest fns-tests-string-bytes () + (should (= (string-bytes "abc") 3))) + ;; Test that equality predicates work correctly on NaNs when combined ;; with hash tables based on those predicates. This was not the case ;; for eql in Emacs 26.