summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-12-23 19:49:58 +0100
committerAndrea Corallo <akrl@sdf.org>2020-12-23 19:49:58 +0100
commitb99a4744822a11e4af098b63db18f54a4e323d58 (patch)
treea3836dfbd6bf4ebfc5b61c566d146cfd65984f62 /test/lisp/emacs-lisp
parentffcd490cb49ba86d625288ea425d98e8cac22a05 (diff)
parent40bc77d9a6b8d824690fb6ee3003d74951bb3ae5 (diff)
downloademacs-b99a4744822a11e4af098b63db18f54a4e323d58.tar.gz
emacs-b99a4744822a11e4af098b63db18f54a4e323d58.tar.bz2
emacs-b99a4744822a11e4af098b63db18f54a4e323d58.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/subr-x-tests.el41
1 files changed, 41 insertions, 0 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 @@
(should (equal (string-remove-suffix "a" "aa") "a"))
(should (equal (string-remove-suffix "a" "ba") "b")))
+(ert-deftest subr-clean-whitespace ()
+ (should (equal (string-clean-whitespace " foo ") "foo"))
+ (should (equal (string-clean-whitespace " foo \r\n\t  Bar") "foo Bar")))
+
+(ert-deftest subr-string-fill ()
+ (should (equal (string-fill "foo" 10) "foo"))
+ (should (equal (string-fill "foobar" 5) "foobar"))
+ (should (equal (string-fill "foo bar zot" 5) "foo\nbar\nzot"))
+ (should (equal (string-fill "foo bar zot" 7) "foo bar\nzot")))
+
+(ert-deftest subr-string-limit ()
+ (should (equal (string-limit "foo" 10) "foo"))
+ (should (equal (string-limit "foo" 2) "fo"))
+ (should (equal (string-limit "foo" 2 t) "oo"))
+ (should (equal (string-limit "abc" 10 t) "abc"))
+ (should (equal (string-limit "foo" 0) ""))
+ (should-error (string-limit "foo" -1)))
+
+(ert-deftest subr-string-lines ()
+ (should (equal (string-lines "foo") '("foo")))
+ (should (equal (string-lines "foo \nbar") '("foo " "bar"))))
+
+(ert-deftest subr-string-slice ()
+ (should (equal (string-slice "foo-bar" "-") '("foo" "-bar")))
+ (should (equal (string-slice "foo-bar-" "-") '("foo" "-bar" "-")))
+ (should (equal (string-slice "-foo-bar-" "-") '("-foo" "-bar" "-")))
+ (should (equal (string-slice "ooo" "lala") '("ooo")))
+ (should (equal (string-slice "foo bar" "\\b") '("foo" " " "bar" "")))
+ (should (equal (string-slice "foo bar" "\\b\\|a") '("foo" " " "b" "ar" ""))))
+
+(ert-deftest subr-string-pad ()
+ (should (equal (string-pad "foo" 5) "foo "))
+ (should (equal (string-pad "foo" 5 ?-) "foo--"))
+ (should (equal (string-pad "foo" 5 ?- t) "--foo"))
+ (should (equal (string-pad "foo" 2 ?-) "foo")))
+
+(ert-deftest subr-string-chop-newline ()
+ (should (equal (string-chop-newline "foo\n") "foo"))
+ (should (equal (string-chop-newline "foo\nbar\n") "foo\nbar"))
+ (should (equal (string-chop-newline "foo\nbar") "foo\nbar")))
+
(provide 'subr-x-tests)
;;; subr-x-tests.el ends here