aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrea Corallo2020-12-23 19:49:58 +0100
committerAndrea Corallo2020-12-23 19:49:58 +0100
commitb99a4744822a11e4af098b63db18f54a4e323d58 (patch)
treea3836dfbd6bf4ebfc5b61c566d146cfd65984f62 /test
parentffcd490cb49ba86d625288ea425d98e8cac22a05 (diff)
parent40bc77d9a6b8d824690fb6ee3003d74951bb3ae5 (diff)
downloademacs-b99a4744822a11e4af098b63db18f54a4e323d58.tar.gz
emacs-b99a4744822a11e4af098b63db18f54a4e323d58.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/subr-x-tests.el41
-rw-r--r--test/lisp/progmodes/xref-tests.el6
-rw-r--r--test/src/fileio-tests.el6
3 files changed, 50 insertions, 3 deletions
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el
index 9d14a5ab7ec..3fc5f1d3ed3 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -582,5 +582,46 @@
582 (should (equal (string-remove-suffix "a" "aa") "a")) 582 (should (equal (string-remove-suffix "a" "aa") "a"))
583 (should (equal (string-remove-suffix "a" "ba") "b"))) 583 (should (equal (string-remove-suffix "a" "ba") "b")))
584 584
585(ert-deftest subr-clean-whitespace ()
586 (should (equal (string-clean-whitespace " foo ") "foo"))
587 (should (equal (string-clean-whitespace " foo \r\n\t  Bar") "foo Bar")))
588
589(ert-deftest subr-string-fill ()
590 (should (equal (string-fill "foo" 10) "foo"))
591 (should (equal (string-fill "foobar" 5) "foobar"))
592 (should (equal (string-fill "foo bar zot" 5) "foo\nbar\nzot"))
593 (should (equal (string-fill "foo bar zot" 7) "foo bar\nzot")))
594
595(ert-deftest subr-string-limit ()
596 (should (equal (string-limit "foo" 10) "foo"))
597 (should (equal (string-limit "foo" 2) "fo"))
598 (should (equal (string-limit "foo" 2 t) "oo"))
599 (should (equal (string-limit "abc" 10 t) "abc"))
600 (should (equal (string-limit "foo" 0) ""))
601 (should-error (string-limit "foo" -1)))
602
603(ert-deftest subr-string-lines ()
604 (should (equal (string-lines "foo") '("foo")))
605 (should (equal (string-lines "foo \nbar") '("foo " "bar"))))
606
607(ert-deftest subr-string-slice ()
608 (should (equal (string-slice "foo-bar" "-") '("foo" "-bar")))
609 (should (equal (string-slice "foo-bar-" "-") '("foo" "-bar" "-")))
610 (should (equal (string-slice "-foo-bar-" "-") '("-foo" "-bar" "-")))
611 (should (equal (string-slice "ooo" "lala") '("ooo")))
612 (should (equal (string-slice "foo bar" "\\b") '("foo" " " "bar" "")))
613 (should (equal (string-slice "foo bar" "\\b\\|a") '("foo" " " "b" "ar" ""))))
614
615(ert-deftest subr-string-pad ()
616 (should (equal (string-pad "foo" 5) "foo "))
617 (should (equal (string-pad "foo" 5 ?-) "foo--"))
618 (should (equal (string-pad "foo" 5 ?- t) "--foo"))
619 (should (equal (string-pad "foo" 2 ?-) "foo")))
620
621(ert-deftest subr-string-chop-newline ()
622 (should (equal (string-chop-newline "foo\n") "foo"))
623 (should (equal (string-chop-newline "foo\nbar\n") "foo\nbar"))
624 (should (equal (string-chop-newline "foo\nbar") "foo\nbar")))
625
585(provide 'subr-x-tests) 626(provide 'subr-x-tests)
586;;; subr-x-tests.el ends here 627;;; subr-x-tests.el ends here
diff --git a/test/lisp/progmodes/xref-tests.el b/test/lisp/progmodes/xref-tests.el
index 038f9d0e304..e220d09dada 100644
--- a/test/lisp/progmodes/xref-tests.el
+++ b/test/lisp/progmodes/xref-tests.el
@@ -52,8 +52,8 @@
52 (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 1 locs)))) 52 (should (string-match-p "file1\\.txt\\'" (xref-location-group (nth 1 locs))))
53 (should (equal 1 (xref-location-line (nth 0 locs)))) 53 (should (equal 1 (xref-location-line (nth 0 locs))))
54 (should (equal 1 (xref-location-line (nth 1 locs)))) 54 (should (equal 1 (xref-location-line (nth 1 locs))))
55 (should (equal 0 (xref-file-location-column (nth 0 locs)))) 55 (should (equal 0 (xref-location-column (nth 0 locs))))
56 (should (equal 4 (xref-file-location-column (nth 1 locs)))))) 56 (should (equal 4 (xref-location-column (nth 1 locs))))))
57 57
58(ert-deftest xref-matches-in-directory-finds-an-empty-line-regexp-match () 58(ert-deftest xref-matches-in-directory-finds-an-empty-line-regexp-match ()
59 (let* ((matches (xref-matches-in-directory "^$" "*" xref-tests-data-dir nil)) 59 (let* ((matches (xref-matches-in-directory "^$" "*" xref-tests-data-dir nil))
@@ -61,7 +61,7 @@
61 (should (= 1 (length matches))) 61 (should (= 1 (length matches)))
62 (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs)))) 62 (should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs))))
63 (should (equal 1 (xref-location-line (nth 0 locs)))) 63 (should (equal 1 (xref-location-line (nth 0 locs))))
64 (should (equal 0 (xref-file-location-column (nth 0 locs)))))) 64 (should (equal 0 (xref-location-column (nth 0 locs))))))
65 65
66(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 () 66(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
67 (let* ((xrefs (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil)) 67 (let* ((xrefs (xref-matches-in-directory "foo" "*" xref-tests-data-dir nil))
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index ed381d151ee..8d46abf342a 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -155,3 +155,9 @@ Also check that an encoding error can appear in a symlink."
155 (write-region "hello\n" nil f nil 'silent) 155 (write-region "hello\n" nil f nil 'silent)
156 (should-error (insert-file-contents f) :type 'circular-list) 156 (should-error (insert-file-contents f) :type 'circular-list)
157 (delete-file f))) 157 (delete-file f)))
158
159(ert-deftest fileio-tests/null-character ()
160 (should-error (file-exists-p "/foo\0bar")
161 :type 'wrong-type-argument))
162
163;;; fileio-tests.el ends here