1 ;; Tests for operations on toc
3 (add-to-list 'load-path
".")
7 (ert-deftest toc-asserts
()
8 "Check some assertions."
9 (should (equal ert-Buf-point-char
"\^@"))
10 (should (equal ert-Buf-mark-char
"\^?"))
13 (ert-deftest rst-toc-insert
()
14 "Tests `rst-toc-insert'."
37 ;; Set customizable variables to defaults
38 (let ((rst-toc-indent 2)
39 (rst-toc-insert-style 'fixed
)
40 (rst-toc-insert-number-separator " ")
41 (rst-toc-insert-max-level nil
))
42 ;; Can't identify a title so do nothing - that's actually a (MIS-)FEATURE
43 (should (ert-equal-buffer
45 (concat "\^@" headers
)
47 ;; Won't work on a section title
48 (should (ert-equal-buffer
50 (concat title
"\^@" headers
)
53 (should (ert-equal-buffer
55 (concat title
"\^@\n\n" headers
)
56 (concat title
"1 Header A
59 2.1.1 SubSubheader B.a.1
65 (should (ert-equal-buffer
67 (concat title
" \^@\n\n" headers
)
68 (concat title
" 1 Header A
71 2.1.1 SubSubheader B.a.1
77 (should (ert-equal-buffer
79 (concat title
" \^@\n\n" headers
)
80 (concat title
" 1 Header A
85 ;; Prefix and indentation
86 (should (ert-equal-buffer
88 (concat title
".. \^@\n\n" headers
)
89 (concat title
".. 1 Header A
92 2.1.1 SubSubheader B.a.1
100 (ert-deftest rst-toc-update
()
101 "Tests `rst-toc-update'."
124 (contents ".. contents:: Inhalt\n")
125 (fields " :bla: blub\n :local:\n")
133 2.1.1 SubSubheader B.a.1
137 ;; Set customizable variables to defaults
138 (let ((rst-toc-indent 2)
139 (rst-toc-insert-style 'fixed
)
140 (rst-toc-insert-number-separator " ")
141 (rst-toc-insert-max-level nil
))
142 (should (ert-equal-buffer
144 (concat title contents fields old
"\n\n" headers
"\^@")
145 (concat title contents fields new
"\n\n" headers
"\^@")))
146 (should (ert-equal-buffer
148 (concat title contents old
"\n\n" headers
"\^@")
149 (concat title contents new
"\n\n" headers
"\^@")))
154 "Call `rst-toc' and copy special buffer to target buffer."
155 (let ((wincfg (current-window-configuration))
157 (if (get-buffer rst-toc-buffer-name
)
158 (kill-buffer rst-toc-buffer-name
))
160 (with-current-buffer rst-toc-buffer-name
161 (setq txt
(buffer-substring-no-properties (point-min) (point-max)))
164 (set-window-configuration wincfg
)
165 (kill-buffer rst-toc-buffer-name
)
166 (delete-region (point-min) (point-max))
171 (ert-deftest rst-toc
()
173 ;; Set customizable variables to defaults
174 (let ((rst-toc-indent 2))
175 (should (ert-equal-buffer
209 (should (ert-equal-buffer
243 (should (ert-equal-buffer
269 "\^@Table of Contents:
279 (should (ert-equal-buffer
308 \^@ SubSubheader B.a.1
315 ;; FIXME: More functions to test:
316 ;; * rst-toc-mode-goto-section