branch: externals/hyperbole
commit e5b65960a641880676e9f3c5fc9f0fc054c812ae
Merge: 3f66e31b88 6c6fc5b02e
Author: bw <[email protected]>
Commit: bw <[email protected]>
Merge branch 'master' into rsw
---
ChangeLog | 5 +++++
test/hypb-tests.el | 64 ++++++++++++++++++++++++++++++++++++++----------------
2 files changed, 50 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5b28f52d2a..abfe394df0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,11 @@
for existing pathnames only. This prevents matching to badly formatted
text
strings and allows 'smart-prog-at-tag-p' and 'smart-prog-tag' to work
properly.
+2025-09-14 Mats Lidell <[email protected]>
+
+* test/hypb-tests.el (hypb--in-string-p--max-lines): Update test.
+ (hypb--string-count-matches): Add test.
+`
2025-09-08 Bob Weiner <[email protected]>
* hsys-xref.el (hsys-xref-identifier-at-point): Clarify doc string.
diff --git a/test/hypb-tests.el b/test/hypb-tests.el
index 4a628a61e3..82fb2a70ac 100644
--- a/test/hypb-tests.el
+++ b/test/hypb-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 5-Apr-21 at 18:53:10
-;; Last-Mod: 6-Jul-25 at 14:49:57 by Bob Weiner
+;; Last-Mod: 14-Sep-25 at 15:53:43 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -106,24 +106,50 @@ See Emacs bug#74042 related to usage of texi2any."
(should (and beg end (= (- end beg) 3))))))))))
(ert-deftest hypb--in-string-p--max-lines ()
- "Verify max lines handing by `hypb:in-string-p'."
- (with-temp-buffer
- (insert "\
-\"1
-2
-\"")
- (goto-line 1) (move-to-column 1)
- ;; First line. Line starts with quote.
- (should-not (hypb:in-string-p 1))
- (should (hypb:in-string-p 2))
- (should (hypb:in-string-p 3))
- (should (hypb:in-string-p 99))
-
- ;; Second line. No quote on the line.
- (goto-line 2)
- (should-not (hypb:in-string-p 1))
- (should (hypb:in-string-p 2))
- (should (hypb:in-string-p 3))))
+ "Verify max lines handling by `hypb:in-string-p'."
+ (let* ((str "1\n\\\"2\n")
+ (range (list str 2 8)))
+ (with-temp-buffer
+ (insert (format "\"%s\"" str))
+ (goto-line 1) (move-to-column 1)
+ ;; First line. Line starts with quote.
+ (should-not (hypb:in-string-p 1))
+ (should (hypb:in-string-p 2))
+ (should (hypb:in-string-p 3))
+ (should (hypb:in-string-p 99))
+
+ ;; With range-flag
+ (should (equal range (hypb:in-string-p 2 t)))
+ (should (equal range (hypb:in-string-p 3 t)))
+ (should (equal range (hypb:in-string-p 99 t)))
+
+ ;; Zero max-lines
+ (should-not (hypb:in-string-p 0))
+
+ ;; Second line. No quote on the line.
+ (goto-line 2)
+ (should-not (hypb:in-string-p 1))
+ (should (hypb:in-string-p 2))
+ (should (hypb:in-string-p 3))
+
+ ;; With range-flag
+ (should (equal range (hypb:in-string-p 2 t)))
+ (should (equal range (hypb:in-string-p 3 t))))))
+
+(ert-deftest hypb--string-count-matches ()
+ "Verify `hypb--string-count-matches'."
+ (should (= 2 (hypb:string-count-matches "a" "abcabd")))
+ (should (= 1 (hypb:string-count-matches "a" "abcabd" 0 2)))
+ (should (= 0 (hypb:string-count-matches "a" "abcabd" 1 3)))
+ (should (= 1 (hypb:string-count-matches "a" "abcabd" 1 4)))
+ ;; Overlap
+ (should (= 1 (hypb:string-count-matches "aba" "ababa")))
+ (should (= 2 (hypb:string-count-matches "aba" "abababa")))
+ ;; Errors
+ (should-error (hypb:string-count-matches "a" "abc" -1 1))
+ (should-error (hypb:string-count-matches "a" "a" 1 3))
+ (should-error (hypb:string-count-matches "a" "a" 0 -1))
+ (should-error (hypb:string-count-matches "a" "ab" 0 3)))
;; This file can't be byte-compiled without the `el-mock' package (because of
;; the use of the `with-mock' macro), which is not a dependency of Hyperbole.