summaryrefslogtreecommitdiff
path: root/test/lisp/replace-tests.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-07-05 16:30:43 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-07-05 16:30:43 +0200
commita111978de8fa28256a208d823b68a37188dfa7f0 (patch)
treef9d007933fbb12c5425e405493b77abb9ac81c88 /test/lisp/replace-tests.el
parent26b9564bd53685533f71e6e102f5bbf575e0c6af (diff)
downloademacs-a111978de8fa28256a208d823b68a37188dfa7f0.tar.gz
Count zero-length matches in `count-matches' correctly
* lisp/replace.el (how-many): Count zero-length matches correctly (bug#27359).
Diffstat (limited to 'test/lisp/replace-tests.el')
-rw-r--r--test/lisp/replace-tests.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 2db570c97dd..6d004e657d0 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -601,4 +601,15 @@ bound to HIGHLIGHT-LOCUS."
(if (match-string 2) "R" "L")))
(should (equal (buffer-string) after)))))
+(ert-deftest test-count-matches ()
+ (with-temp-buffer
+ (insert "oooooooooo")
+ (goto-char (point-min))
+ (should (= (count-matches "oo") 5))
+ (should (= (count-matches "o+") 1)))
+ (with-temp-buffer
+ (insert "o\n\n\n\no\n\n")
+ (goto-char (point-min))
+ (should (= (count-matches "^$") 4))))
+
;;; replace-tests.el ends here