aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorEric S. Raymond2026-02-25 17:06:50 -0500
committerEric S. Raymond2026-02-25 17:06:50 -0500
commitfc7339c46dc87d5d7051f976206bb5c4d9efdfb8 (patch)
tree6f681137059827a24eca1e96587accf6344f4ed3 /test/src
parentfeac53141577161c32a7a6dfe75399a5ae98a7c1 (diff)
downloademacs-fc7339c46dc87d5d7051f976206bb5c4d9efdfb8.tar.gz
emacs-fc7339c46dc87d5d7051f976206bb5c4d9efdfb8.zip
More test coverage improvements.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/data-tests.el5
-rw-r--r--test/src/floatfns-tests.el15
-rw-r--r--test/src/fns-tests.el52
-rw-r--r--test/src/keymap-tests.el16
-rw-r--r--test/src/minibuf-tests.el4
5 files changed, 92 insertions, 0 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 7c0796c5d2a..deec9feead7 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -85,6 +85,11 @@ this is exactly representable and is greater than
85 (should (equal (subr-name (symbol-function 'cons)) "cons")) 85 (should (equal (subr-name (symbol-function 'cons)) "cons"))
86 (should (equal (subr-name (symbol-function 'if)) "if"))) 86 (should (equal (subr-name (symbol-function 'if)) "if")))
87 87
88(ert-deftest data-tests-byteorder ()
89 (let ((bo (byteorder)))
90 (should (integerp bo))
91 (should (memq bo (list ?B ?l)))))
92
88(ert-deftest data-tests-= () 93(ert-deftest data-tests-= ()
89 (should-error (=)) 94 (should-error (=))
90 (should (= 1)) 95 (should (= 1))
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el
index 49e76b809a3..cdd8865410c 100644
--- a/test/src/floatfns-tests.el
+++ b/test/src/floatfns-tests.el
@@ -31,6 +31,21 @@
31(ert-deftest floatfns-tests-tan () 31(ert-deftest floatfns-tests-tan ()
32 (should (= (tan 0) 0.0))) 32 (should (= (tan 0) 0.0)))
33 33
34(ert-deftest floatfns-tests-asin-acos-atan ()
35 (let ((eps 1e-12))
36 (should (< (abs (- (asin 0.0) 0.0)) eps))
37 (should (< (abs (- (asin 1.0) (/ float-pi 2))) eps))
38 (should (< (abs (- (acos 1.0) 0.0)) eps))
39 (should (< (abs (- (acos 0.0) (/ float-pi 2))) eps))
40 (should (< (abs (- (atan 0.0) 0.0)) eps))
41 (should (< (abs (- (atan 1.0) (/ float-pi 4))) eps))))
42
43(ert-deftest floatfns-tests-copysign ()
44 (should (= (copysign 1.0 2.0) 1.0))
45 (should (= (copysign 1.0 -2.0) -1.0))
46 (should (= (copysign -1.0 2.0) 1.0))
47 (should (= (copysign -1.0 -2.0) -1.0)))
48
34(ert-deftest floatfns-tests-isnan () 49(ert-deftest floatfns-tests-isnan ()
35 (should (isnan 0.0e+NaN)) 50 (should (isnan 0.0e+NaN))
36 (should (isnan -0.0e+NaN)) 51 (should (isnan -0.0e+NaN))
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index 0288e3a460e..955b3cbe7fb 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -535,6 +535,58 @@
535 (should (equal (fns-tests--with-region base64-encode-region "\x14\xfb\x9c\x03\xd9\x7e") "FPucA9l+")) 535 (should (equal (fns-tests--with-region base64-encode-region "\x14\xfb\x9c\x03\xd9\x7e") "FPucA9l+"))
536 (should (equal (fns-tests--with-region base64-encode-region "\x14\xfb\x9c\x03\xd9\x7f") "FPucA9l/"))) 536 (should (equal (fns-tests--with-region base64-encode-region "\x14\xfb\x9c\x03\xd9\x7f") "FPucA9l/")))
537 537
538(defun fns-tests--base64-decode-region (input &optional base64url ignore-invalid)
539 (with-temp-buffer
540 (set-buffer-multibyte nil)
541 (insert input)
542 (let ((len (base64-decode-region (point-min) (point-max)
543 base64url ignore-invalid)))
544 (list len (buffer-string)))))
545
546(defun fns-tests--as-unibyte (string)
547 (encode-coding-string string 'binary))
548
549(ert-deftest fns-tests-base64-decode-region ()
550 ;; standard variant RFC2045
551 (should (equal (fns-tests--base64-decode-region "") '(0 "")))
552 (should (equal (fns-tests--base64-decode-region "Zg==") '(1 "f")))
553 (should (equal (fns-tests--base64-decode-region "Zm8=") '(2 "fo")))
554 (should (equal (fns-tests--base64-decode-region "Zm9v") '(3 "foo")))
555 (should (equal (fns-tests--base64-decode-region "Zm9vYg==") '(4 "foob")))
556 (should (equal (fns-tests--base64-decode-region "Zm9vYmE=") '(5 "fooba")))
557 (should (equal (fns-tests--base64-decode-region "Zm9vYmFy") '(6 "foobar")))
558 (let* ((res (fns-tests--base64-decode-region "FPucA9l+"))
559 (len (nth 0 res))
560 (out (nth 1 res)))
561 (should (= len (string-bytes out)))
562 (should (equal (fns-tests--as-unibyte out)
563 (fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7e"))))
564 (let* ((res (fns-tests--base64-decode-region "FPucA9l/"))
565 (len (nth 0 res))
566 (out (nth 1 res)))
567 (should (= len (string-bytes out)))
568 (should (equal (fns-tests--as-unibyte out)
569 (fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7f"))))
570
571 ;; url variant
572 (let* ((res (fns-tests--base64-decode-region "FPucA9l-" t))
573 (len (nth 0 res))
574 (out (nth 1 res)))
575 (should (= len (string-bytes out)))
576 (should (equal (fns-tests--as-unibyte out)
577 (fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7e"))))
578 (let* ((res (fns-tests--base64-decode-region "FPucA9l_" t))
579 (len (nth 0 res))
580 (out (nth 1 res)))
581 (should (= len (string-bytes out)))
582 (should (equal (fns-tests--as-unibyte out)
583 (fns-tests--as-unibyte "\x14\xfb\x9c\x03\xd9\x7f"))))
584
585 ;; ignore invalid characters
586 (should (equal (fns-tests--base64-decode-region "Zg==@" nil t) '(1 "f")))
587 (should (equal (fns-tests--base64-decode-region "Zg==@" t t) '(1 "f")))
588 (should-error (fns-tests--base64-decode-region "Zg=")))
589
538(ert-deftest fns-tests-base64-encode-string () 590(ert-deftest fns-tests-base64-encode-string ()
539 ;; standard variant RFC2045 591 ;; standard variant RFC2045
540 (should (equal (base64-encode-string "") "")) 592 (should (equal (base64-encode-string "") ""))
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index c53ab7871c3..004ec1cee04 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -37,6 +37,22 @@
37(ert-deftest keymap-make-sparse-keymap () 37(ert-deftest keymap-make-sparse-keymap ()
38 (keymap-tests--make-keymap-test #'make-sparse-keymap)) 38 (keymap-tests--make-keymap-test #'make-sparse-keymap))
39 39
40(ert-deftest keymap-accessible-keymaps ()
41 (let* ((map (make-sparse-keymap))
42 (sub (make-sparse-keymap)))
43 (define-key map (kbd "C-x") sub)
44 (define-key sub (kbd "C-f") #'find-file)
45 (define-key map (kbd "C-c") #'ignore)
46 (let ((maps (accessible-keymaps map)))
47 (should (equal (caar maps) []))
48 (should (eq (cdar maps) map))
49 (should (assoc [?\C-x] maps))
50 (should (eq (cdr (assoc [?\C-x] maps)) sub))
51 (should-not (assoc [?\C-c] maps)))
52 (let ((pref (accessible-keymaps map (kbd "C-x"))))
53 (should (equal (caar pref) [?\C-x]))
54 (should (eq (cdar pref) sub)))))
55
40(ert-deftest keymap-keymapp () 56(ert-deftest keymap-keymapp ()
41 (should (keymapp (make-keymap))) 57 (should (keymapp (make-keymap)))
42 (should (keymapp (make-sparse-keymap))) 58 (should (keymapp (make-sparse-keymap)))
diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el
index 5bfbe710b10..36ca3604acf 100644
--- a/test/src/minibuf-tests.el
+++ b/test/src/minibuf-tests.el
@@ -431,5 +431,9 @@
431 (error nil)) 431 (error nil))
432 'inhibit)))) 432 'inhibit))))
433 433
434(ert-deftest minibuf-tests-active-minibuffer-window ()
435 (should-not (active-minibuffer-window))
436 (should (windowp (minibuffer-window))))
437
434 438
435;;; minibuf-tests.el ends here 439;;; minibuf-tests.el ends here