;;; occur-tests.el --- Test suite for occur.
-;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2015 Free Software Foundation, Inc.
;; Author: Juri Linkov <juri@jurta.org>
;; Keywords: matching, internal
xex
fx
" "\
-5 matches for \"x\" in buffer: *test-occur*
+6 matches in 5 lines for \"x\" in buffer: *test-occur*
1:xa
3:cx
4:xd
a
a
" "\
-2 matches for \"a^Ja\" in buffer: *test-occur*
+2 matches for \"a\na\" in buffer: *test-occur*
1:a
:a
3:a
a
b
" "\
-2 matches for \"a^Jb\" in buffer: *test-occur*
+2 matches for \"a\nb\" in buffer: *test-occur*
1:a
:b
4:a
a
" "\
-2 matches for \"a^J\" in buffer: *test-occur*
+2 matches for \"a\n\" in buffer: *test-occur*
1:a
:
4:a
ex
fx
" "\
-2 matches for \"x^J.x^J\" in buffer: *test-occur*
+2 matches for \"x\n.x\n\" in buffer: *test-occur*
1:ax
:bx
:c
jx
kx
" "\
-3 matches for \"x^J.x\" in buffer: *test-occur*
+3 matches for \"x\n.x\" in buffer: *test-occur*
1:ax
:bx
:c
gx
hx
" "\
-2 matches for \"x^J.x\" in buffer: *test-occur*
+2 matches for \"x\n.x\" in buffer: *test-occur*
1:ax
:bx
:c
(let ((regexp (nth 0 test))
(nlines (nth 1 test))
(input-buffer-string (nth 2 test))
- (output-buffer-string (nth 3 test))
(temp-buffer (get-buffer-create " *test-occur*")))
(unwind-protect
(save-window-excursion
(erase-buffer)
(insert input-buffer-string)
(occur regexp nlines)
- (equal output-buffer-string
- (with-current-buffer "*Occur*"
- (buffer-string)))))
+ (with-current-buffer "*Occur*"
+ (buffer-substring-no-properties (point-min) (point-max)))))
(and (buffer-name temp-buffer)
(kill-buffer temp-buffer)))))
-(ert-deftest occur-tests ()
- "Test the functionality of `occur'.
-The test data is in the `occur-tests' constant."
- (let ((occur-hook nil))
- (dolist (test occur-tests)
- (should (occur-test-case test)))))
+(defun occur-test-create (n)
+ "Create a test for element N of the `occur-tests' constant."
+ (let ((testname (intern (format "occur-test-%.2d" n)))
+ (testdoc (format "Test element %d of `occur-tests'." n)))
+ (eval
+ `(ert-deftest ,testname ()
+ ,testdoc
+ (let (occur-hook)
+ (should (equal (occur-test-case (nth ,n occur-tests))
+ (nth 3 (nth ,n occur-tests)))))))))
+
+(dotimes (i (length occur-tests))
+ (occur-test-create i))
(provide 'occur-tests)