1 ;; Tests for class `rst-Stn' -*- lexical-binding: t -*-
3 (add-to-list 'load-path
".")
7 (ert-deftest rst-Stn-new
()
32 (ado-T (rst-Ado-new-over-and-under ?
=))
33 (ttl-T (rst-Ttl--new ado-T
'(1 18 1 6 7 12 13 18) 0
35 (ado-A (rst-Ado-new-simple ?
=))
36 (ttl-A (rst-Ttl--new ado-A
'(20 37 nil nil
20 28 29 37) 0
38 (ttl-B (rst-Ttl--new ado-A
'(39 56 nil nil
39 47 48 56) 0
40 (ado-Ba (rst-Ado-new-simple ?-
))
41 (ttl-Ba (rst-Ttl--new ado-Ba
'(58 85 nil nil
58 71 72 85) 0
43 (ado-Ba1 (rst-Ado-new-simple ?~
))
44 (ttl-Ba1 (rst-Ttl--new ado-Ba1
'(87 124 nil nil
87 105 106 124) 0
45 "SubSubheader B.a.1"))
46 (ttl-C (rst-Ttl--new ado-A
'(126 143 nil nil
126 134 135 143) 0
49 (ttl-Ca1 (rst-Ttl--new ado-Ba1
'(145 182 nil nil
145 163 164 182) 0
50 "Missing node C.a.1")))
52 (should-error (rst-Stn-new "" 0 nil
)
53 :type
'wrong-type-argument
)
54 (should-error (rst-Stn-new nil
"0" nil
)
55 :type
'wrong-type-argument
)
56 (should-error (rst-Stn-new nil
0 "")
57 :type
'wrong-type-argument
)
58 (should-error (rst-Stn-new nil
0 '(1))
59 :type
'wrong-type-argument
)
61 (should-error (rst-Stn-new nil
0 nil
)
62 :type
'args-out-of-range
)
64 (should-error (rst-Stn-new ttl-T -
1 nil
)
65 :type
'args-out-of-range
)
68 (rst-Stn-new ttl-T
0 nil
)))
72 (list (rst-Stn-new ttl-A
1 nil
)))))
76 (list (rst-Stn-new ttl-A
1 nil
)
77 (rst-Stn-new ttl-B
1 nil
)
78 (rst-Stn-new ttl-C
1 nil
)))))
82 (list (rst-Stn-new ttl-A
1 nil
)
87 (list (rst-Stn-new ttl-Ba1
3 nil
)))))
92 (list (rst-Stn-new ttl-Ca1
3 nil
)))))))))
95 (ert-deftest rst-Stn-get-title-beginning
()
96 "Test `rst-Stn-get-title-beginning'."
111 ;; SubSubheader B.a.1
112 ;; ~~~~~~~~~~~~~~~~~~
117 ;; Missing node C.a.1
118 ;; ~~~~~~~~~~~~~~~~~~
120 (ado-T (rst-Ado-new-over-and-under ?
=))
121 (ttl-T (rst-Ttl--new ado-T
'(1 18 1 6 7 12 13 18) 0
123 (ado-A (rst-Ado-new-simple ?
=))
124 (ttl-A (rst-Ttl--new ado-A
'(20 37 nil nil
20 28 29 37) 0
126 (ttl-B (rst-Ttl--new ado-A
'(39 56 nil nil
39 47 48 56) 0
128 (ado-Ba (rst-Ado-new-simple ?-
))
129 (ttl-Ba (rst-Ttl--new ado-Ba
'(58 85 nil nil
58 71 72 85) 0
131 (ado-Ba1 (rst-Ado-new-simple ?~
))
132 (ttl-Ba1 (rst-Ttl--new ado-Ba1
'(87 124 nil nil
87 105 106 124) 0
133 "SubSubheader B.a.1"))
134 (ttl-C (rst-Ttl--new ado-A
'(126 143 nil nil
126 134 135 143) 0
137 (ttl-Ca1 (rst-Ttl--new ado-Ba1
'(145 182 nil nil
145 163 164 182) 0
138 "Missing node C.a.1")))
139 (let* ((stn-Ca (rst-Stn-new
141 (list (rst-Stn-new ttl-Ca1
3 nil
))))
145 (stn-A (rst-Stn-new ttl-A
1 nil
))
150 (list (rst-Stn-new ttl-Ba1
3 nil
))))))
156 (should-error (rst-Stn-get-title-beginning "")
157 :type
'wrong-type-argument
)
159 (should (equal (rst-Stn-get-title-beginning stn-T
) 7))
160 (should (equal (rst-Stn-get-title-beginning stn-B
) 39))
161 (should (equal (rst-Stn-get-title-beginning stn-A
) 20))
162 (should (equal (rst-Stn-get-title-beginning stn-C
) 126))
163 (should (equal (rst-Stn-get-title-beginning stn-Ca
) 145))
166 (ert-deftest rst-Stn-get-text
()
167 "Test `rst-Stn-get-text'."
182 ;; SubSubheader B.a.1
183 ;; ~~~~~~~~~~~~~~~~~~
188 ;; Missing node C.a.1
189 ;; ~~~~~~~~~~~~~~~~~~
191 (ado-T (rst-Ado-new-over-and-under ?
=))
192 (ttl-T (rst-Ttl--new ado-T
'(1 18 1 6 7 12 13 18) 0
194 (ado-A (rst-Ado-new-simple ?
=))
195 (ttl-A (rst-Ttl--new ado-A
'(20 37 nil nil
20 28 29 37) 0
197 (ttl-B (rst-Ttl--new ado-A
'(39 56 nil nil
39 47 48 56) 0
199 (ado-Ba (rst-Ado-new-simple ?-
))
200 (ttl-Ba (rst-Ttl--new ado-Ba
'(58 85 nil nil
58 71 72 85) 0
202 (ado-Ba1 (rst-Ado-new-simple ?~
))
203 (ttl-Ba1 (rst-Ttl--new ado-Ba1
'(87 124 nil nil
87 105 106 124) 0
204 "SubSubheader B.a.1"))
205 (ttl-C (rst-Ttl--new ado-A
'(126 143 nil nil
126 134 135 143) 0
208 (ttl-Ca1 (rst-Ttl--new ado-Ba1
'(145 182 nil nil
145 163 164 182) 0
209 "Missing node C.a.1")))
210 (let* ((stn-Ca (rst-Stn-new
212 (list (rst-Stn-new ttl-Ca1
3 nil
))))
216 (stn-A (rst-Stn-new ttl-A
1 nil
))
221 (list (rst-Stn-new ttl-Ba1
3 nil
))))))
227 (should-error (rst-Stn-get-text "")
228 :type
'wrong-type-argument
)
230 (should (equal (rst-Stn-get-text stn-T
) "Title"))
231 (should (equal (rst-Stn-get-text stn-B
"Default") "Header B"))
232 (should (equal (rst-Stn-get-text stn-Ca
"Default") "Default"))
233 (should (rst-Stn-get-text stn-Ca
))
236 (ert-deftest rst-Stn-is-top
()
237 "Test `rst-Stn-is-top'."
243 (ado-T (rst-Ado-new-over-and-under ?
=))
244 (ttl-T (rst-Ttl--new ado-T
'(1 18 1 6 7 12 13 18) 0
246 (let ((stn-T (rst-Stn-new ttl-T
0 nil
)))
247 (should-error (rst-Stn-is-top nil
)
248 :type
'wrong-type-argument
)
249 (should (rst-Stn-is-top (rst-Stn-new
252 (should-not (rst-Stn-is-top stn-T
))