1 ;;; text-property-search-tests.el --- Testing text-property-search
3 ;; Copyright (C) 2018 Free Software Foundation, Inc.
5 ;; Author: Lars Ingebrigtsen <larsi@gnus.org>
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
28 (require 'text-property-search
)
31 (defun text-property-setup ()
33 (propertize "bold1" 'face
'bold
)
35 (propertize "italic1" 'face
'italic
)
36 (propertize "bold2" 'face
'bold
)
37 (propertize "italic2" 'face
'italic
)
39 (goto-char (point-min)))
41 (defmacro with-test
(form result
&optional point
)
48 (cl-loop for match
= ,form
50 collect
(buffer-substring (prop-match-beginning match
)
51 (prop-match-end match
)))
54 (ert-deftest text-property-search-forward-bold-t
()
55 (with-test (text-property-search-forward 'face
'bold t
)
58 (ert-deftest text-property-search-forward-bold-nil
()
59 (with-test (text-property-search-forward 'face
'bold nil
)
60 '("This is " " and this is italic1" "italic2 at the end")))
62 (ert-deftest text-property-search-forward-nil-t
()
63 (with-test (text-property-search-forward 'face nil t
)
64 '("This is " " and this is " " at the end")))
66 (ert-deftest text-property-search-forward-nil-nil
()
67 (with-test (text-property-search-forward 'face nil nil
)
68 '("bold1" "italic1" "bold2" "italic2")))
70 (ert-deftest text-property-search-forward-partial-bold-t
()
71 (with-test (text-property-search-forward 'face
'bold t
)
75 (ert-deftest text-property-search-forward-partial-non-current-bold-t
()
76 (with-test (text-property-search-forward 'face
'bold t t
)
81 (ert-deftest text-property-search-backward-bold-t
()
82 (with-test (text-property-search-backward 'face
'bold t
)
86 (ert-deftest text-property-search-backward-bold-nil
()
87 (with-test (text-property-search-backward 'face
'bold nil
)
88 '( "italic2 at the end" " and this is italic1" "This is ")
91 (ert-deftest text-property-search-backward-nil-t
()
92 (with-test (text-property-search-backward 'face nil t
)
93 '(" at the end" " and this is " "This is ")
96 (ert-deftest text-property-search-backward-nil-nil
()
97 (with-test (text-property-search-backward 'face nil nil
)
98 '("italic2" "bold2" "italic1" "bold1")
101 (ert-deftest text-property-search-backward-partial-bold-t
()
102 (with-test (text-property-search-backward 'face
'bold t
)
106 (ert-deftest text-property-search-backward-partial-non-current-bold-t
()
107 (with-test (text-property-search-backward 'face
'bold t t
)
111 (provide 'text-property-search-tests
)
113 ;;; text-property-search-tests.el ends here