summaryrefslogtreecommitdiff
path: root/test/automated/xref-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/automated/xref-tests.el')
-rw-r--r--test/automated/xref-tests.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/automated/xref-tests.el b/test/automated/xref-tests.el
index b288e2d7584..079b196aa8b 100644
--- a/test/automated/xref-tests.el
+++ b/test/automated/xref-tests.el
@@ -60,3 +60,32 @@
(should (string-match-p "file2\\.txt\\'" (xref-location-group (nth 0 locs))))
(should (equal 1 (xref-location-line (nth 0 locs))))
(should (equal 0 (xref-file-location-column (nth 0 locs))))))
+
+(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-1 ()
+ (let* ((xrefs (xref-collect-matches "foo" "*" xref-tests-data-dir nil))
+ (iter (xref--buf-pairs-iterator xrefs))
+ (cons (funcall iter :next)))
+ (should (null (funcall iter :next)))
+ (should (string-match "file1\\.txt\\'" (buffer-file-name (car cons))))
+ (should (= 2 (length (cdr cons))))))
+
+(ert-deftest xref--buf-pairs-iterator-groups-markers-by-buffers-2 ()
+ (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
+ (iter (xref--buf-pairs-iterator xrefs))
+ (cons1 (funcall iter :next))
+ (cons2 (funcall iter :next)))
+ (should (null (funcall iter :next)))
+ (should-not (equal (car cons1) (car cons2)))
+ (should (= 1 (length (cdr cons1))))
+ (should (= 1 (length (cdr cons2))))))
+
+(ert-deftest xref--buf-pairs-iterator-cleans-up-markers ()
+ (let* ((xrefs (xref-collect-matches "bar" "*" xref-tests-data-dir nil))
+ (iter (xref--buf-pairs-iterator xrefs))
+ (cons1 (funcall iter :next))
+ (cons2 (funcall iter :next)))
+ (funcall iter :cleanup)
+ (should (null (marker-position (car (nth 0 (cdr cons1))))))
+ (should (null (marker-position (cdr (nth 0 (cdr cons1))))))
+ (should (null (marker-position (car (nth 0 (cdr cons2))))))
+ (should (null (marker-position (cdr (nth 0 (cdr cons2))))))))