Skip to content

Commit

Permalink
Update after review - count entries and not matching lines
Browse files Browse the repository at this point in the history
  • Loading branch information
matsl committed Mar 31, 2024
1 parent 89807dc commit 07891ea
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/hyrolo-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Mats Lidell <matsl@gnu.org>
;;
;; Orig-Date: 19-Jun-21 at 22:42:00
;; Last-Mod: 30-Mar-24 at 23:35:15 by Mats Lidell
;; Last-Mod: 31-Mar-24 at 11:36:33 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -1635,20 +1635,30 @@ body
(hy-delete-files-and-buffers hyrolo-file-list))))

(ert-deftest hyrolo-test--grep-count ()
"Verify number of matches are correct."
"Verify number of matched entries are correct."
:expected-result :failed
(unwind-protect
(with-temp-buffer
(org-mode)
(insert "\
* match
match
* match
other
* other
match
")
;; Count number of entries that have a match
(should (= (hyrolo-grep "match" nil (current-buffer) t nil) 3))
(should (= (hyrolo-grep "match" nil (current-buffer) t t) 1)))
(kill-buffer hyrolo-display-buffer)))
;; Count number of entries that only match on the first line
(should (= (hyrolo-grep "match" nil (current-buffer) t t) 2))
;; Count number of entries that match but not on the first line
(should (= (hyrolo-grep "match" t (current-buffer) t nil) 2))
;; Nothing if there is no match
(should (= (hyrolo-grep "nothing" nil (current-buffer) t nil) 0)))
(and (get-buffer hyrolo-display-buffer)
(kill-buffer hyrolo-display-buffer)
(ert-fail "Buffer %s should not have been created" hyrolo-display-buffer))))

(provide 'hyrolo-tests)

Expand Down

0 comments on commit 07891ea

Please sign in to comment.