Debian Codegraph @

tools/editors/emacs/tests/imenu.el

raw
1 ;; Tests for rst-imenu-create-index -*- lexical-binding: t -*-
2
3 (add-to-list 'load-path ".")
4 (load "init" nil t)
5 (init-rst-ert t)
6
7 (ert-deftest imenu-asserts ()
8 "Check some assertions."
9 (should (equal ert-Buf-point-char "\^@"))
10 (should (equal ert-Buf-mark-char "\^?"))
11 )
12
13 (ert-deftest rst-imenu-create-index ()
14 "Tests for `rst-imenu-create-index'."
15 (should (ert-equal-buffer-return
16 '(rst-imenu-create-index)
17 "
18 "
19 t
20 nil))
21 (should (ert-equal-buffer-return
22 '(rst-imenu-create-index)
23 "
24 Some normal text.
25 "
26 t
27 nil))
28 (should (ert-equal-buffer-return
29 '(rst-imenu-create-index)
30 "
31 Header
32 ======"
33 t
34 '(("=Header" . 2))))
35 (should (ert-equal-buffer-return
36 '(rst-imenu-create-index)
37 "
38 ============
39 Indented
40 ============"
41 t
42 '(("=Indented=" . 15))))
43 (should (ert-equal-buffer-return
44 '(rst-imenu-create-index)
45 "
46 ~~~~~~~~~~~~~~
47 Over and under
48 ~~~~~~~~~~~~~~"
49 t
50 '(("~Over and under~" . 17))))
51 (should (ert-equal-buffer-return
52 '(rst-imenu-create-index)
53 "
54 Header
55 ======
56
57 Subheader
58 ---------"
59 t
60 '(("=Header"
61 ("=Header" . 2)
62 ("-Subheader" . 17)))))
63 (should (ert-equal-buffer-return
64 '(rst-imenu-create-index)
65 "
66 Header
67 ======
68
69 Subheader
70 ---------
71
72 With space
73 ----------"
74 t
75 '(("=Header"
76 ("=Header" . 2)
77 ("-Subheader" . 17)
78 ("-With space" . 38)))))
79 (should (ert-equal-buffer-return
80 '(rst-imenu-create-index)
81 "
82 Header
83 ======
84
85 Subheader
86 ---------
87
88 With space
89 ----------
90
91 Top level again
92 ==============="
93 t
94 '(("=Header"
95 ("=Header" . 2)
96 ("-Subheader" . 17)
97 ("-With space" . 38))
98 ("=Top level again" . 61))))
99 (should (ert-equal-buffer-return
100 '(rst-imenu-create-index)
101 "
102 Header
103 ======
104
105 Subheader
106 ---------
107
108 With space
109 ----------
110
111 Sub sub
112 ~~~~~~~
113
114 Top level again
115 ==============="
116 t
117 '(("=Header"
118 ("=Header" . 2)
119 ("-Subheader" . 17)
120 ("-With space"
121 ("-With space" . 38)
122 ("~Sub sub" . 61)))
123 ("=Top level again" . 78))))
124 )
125
126 ;; FIXME: Test missing intermediate sections.
127 ;; FIXME: Test document titles.