More test coverage improvements.

This commit is contained in:
Eric S. Raymond 2026-02-25 17:06:50 -05:00
parent feac531415
commit fc7339c46d
5 changed files with 92 additions and 0 deletions

View file

@ -85,6 +85,11 @@ this is exactly representable and is greater than
(should (equal (subr-name (symbol-function 'cons)) "cons"))
(should (equal (subr-name (symbol-function 'if)) "if")))
(ert-deftest data-tests-byteorder ()
(let ((bo (byteorder)))
(should (integerp bo))
(should (memq bo (list ?B ?l)))))
(ert-deftest data-tests-= ()
(should-error (=))
(should (= 1))

View file

@ -31,6 +31,21 @@
(ert-deftest floatfns-tests-tan ()
(should (= (tan 0) 0.0)))
(ert-deftest floatfns-tests-asin-acos-atan ()
(let ((eps 1e-12))
(should (< (abs (- (asin 0.0) 0.0)) eps))
(should (< (abs (- (asin 1.0) (/ float-pi 2))) eps))
(should (< (abs (- (acos 1.0) 0.0)) eps))
(should (< (abs (- (acos 0.0) (/ float-pi 2))) eps))
(should (< (abs (- (atan 0.0) 0.0)) eps))
(should (< (abs (- (atan 1.0) (/ float-pi 4))) eps))))
(ert-deftest floatfns-tests-copysign ()
(should (= (copysign 1.0 2.0) 1.0))
(should (= (copysign 1.0 -2.0) -1.0))
(should (= (copysign -1.0 2.0) 1.0))
(should (= (copysign -1.0 -2.0) -1.0)))
(ert-deftest floatfns-tests-isnan ()
(should (isnan 0.0e+NaN))
(should (isnan -0.0e+NaN))

View file

@ -535,6 +535,58 @@
(should (equal (fns-tests--with-region base64-encode-region "\x14\xfb\x9c\x03\xd9\x7e") "FPucA9l+"))
(should (equal (fns-tests--with-region base64-encode-region "\x14\xfb\x9c\x03\xd9\x7f") "FPucA9l/")))
(defun fns-tests--base64-decode-region (input &optional base64url ignore-invalid)
(with-temp-buffer
(set-buffer-multibyte nil)
(insert input)
(let ((len (base64-decode-region (point-min) (point-max)
base64url ignore-invalid)))
(list len (buffer-string)))))
(defun fns-tests--as-unibyte (string)
(encode-coding-string string 'binary))
(ert-deftest fns-tests-base64-decode-region ()
;; standard variant RFC2045
(should (equal (fns-tests--base64-decode-region "") '(0 "")))
(should (equal (fns-tests--base64-decode-region "Zg==") '(1 "f")))
(should (equal (fns-tests--base64-decode-region "Zm8=") '(2 "fo")))
(should (equal (fns-tests--base64-decode-region "Zm9v") '(3 "foo")))
(should (equal (fns-tests--base64-decode-region "Zm9vYg==") '(4 "foob")))
(should (equal (fns-tests--base64-decode-region "Zm9vYmE=") '(5 "fooba")))
(should (equal (fns-tests--base64-decode-region "Zm9vYmFy") '(6 "foobar")))
(let* ((res (fns-tests--base64-decode-region "FPucA9l+"))
(len (nth 0 res))
(out (nth 1 res)))
(should (= len (string-bytes out)))
(should (equal (fns-tests--as-unibyte out)
(fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7e"))))
(let* ((res (fns-tests--base64-decode-region "FPucA9l/"))
(len (nth 0 res))
(out (nth 1 res)))
(should (= len (string-bytes out)))
(should (equal (fns-tests--as-unibyte out)
(fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7f"))))
;; url variant
(let* ((res (fns-tests--base64-decode-region "FPucA9l-" t))
(len (nth 0 res))
(out (nth 1 res)))
(should (= len (string-bytes out)))
(should (equal (fns-tests--as-unibyte out)
(fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7e"))))
(let* ((res (fns-tests--base64-decode-region "FPucA9l_" t))
(len (nth 0 res))
(out (nth 1 res)))
(should (= len (string-bytes out)))
(should (equal (fns-tests--as-unibyte out)
(fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7f"))))
;; ignore invalid characters
(should (equal (fns-tests--base64-decode-region "Zg==@" nil t) '(1 "f")))
(should (equal (fns-tests--base64-decode-region "Zg==@" t t) '(1 "f")))
(should-error (fns-tests--base64-decode-region "Zg=")))
(ert-deftest fns-tests-base64-encode-string ()
;; standard variant RFC2045
(should (equal (base64-encode-string "") ""))

View file

@ -37,6 +37,22 @@
(ert-deftest keymap-make-sparse-keymap ()
(keymap-tests--make-keymap-test #'make-sparse-keymap))
(ert-deftest keymap-accessible-keymaps ()
(let* ((map (make-sparse-keymap))
(sub (make-sparse-keymap)))
(define-key map (kbd "C-x") sub)
(define-key sub (kbd "C-f") #'find-file)
(define-key map (kbd "C-c") #'ignore)
(let ((maps (accessible-keymaps map)))
(should (equal (caar maps) []))
(should (eq (cdar maps) map))
(should (assoc [?\C-x] maps))
(should (eq (cdr (assoc [?\C-x] maps)) sub))
(should-not (assoc [?\C-c] maps)))
(let ((pref (accessible-keymaps map (kbd "C-x"))))
(should (equal (caar pref) [?\C-x]))
(should (eq (cdar pref) sub)))))
(ert-deftest keymap-keymapp ()
(should (keymapp (make-keymap)))
(should (keymapp (make-sparse-keymap)))

View file

@ -431,5 +431,9 @@
(error nil))
'inhibit))))
(ert-deftest minibuf-tests-active-minibuffer-window ()
(should-not (active-minibuffer-window))
(should (windowp (minibuffer-window))))
;;; minibuf-tests.el ends here