From 22c1f00d997d38ba0c453da5f5e9c526d0ac05b0 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 23 Dec 2020 07:45:19 +0100 Subject: Allow string-slice to take zero-length matches * lisp/emacs-lisp/subr-x.el (string-slice): Allow zero-length matches. Code adapted from s.el by Magnar Sveen. --- test/lisp/emacs-lisp/subr-x-tests.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/lisp/emacs-lisp/subr-x-tests.el') diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index 854d61ed28e..3fc5f1d3ed3 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -608,7 +608,9 @@ (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 "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 ")) -- cgit v1.2.3