1 ;; Tests for operations on list items -*- lexical-binding: t -*-
3 (add-to-list 'load-path
".")
7 (ert-deftest items-asserts
()
8 "Check some assertions."
9 (should (equal ert-Buf-point-char
"\^@"))
10 (should (equal ert-Buf-mark-char
"\^?"))
13 (defun find-begs (beg-re)
14 (rst-find-begs (region-beginning) (region-end) beg-re
))
16 (ert-deftest rst-find-begs
()
17 "Tests `rst-find-begs'."
18 (should (ert-equal-buffer-return
19 '(find-begs 'itmany-beg-1
)
20 "\^@1 Normal paragraph.
26 58 Another normal paragraph.
31 (should (ert-equal-buffer-return
32 '(find-begs 'itmany-beg-1
)
39 \^@58 Another normal paragraph.
44 (should (ert-equal-buffer-return
45 '(find-begs 'itmany-beg-1
)
56 \^@95 Another normal paragraph.
63 (should (ert-equal-buffer-return
73 (should (ert-equal-buffer-return
83 (should (ert-equal-buffer-return
93 (should (ert-equal-buffer-return
105 (should (ert-equal-buffer-return
106 '(find-begs 'bul-beg
)
113 Another normal paragraph
119 (ert-deftest rst-find-begs-BUGS
()
120 "Exposes bugs in `rst-find-begs'."
121 :expected-result
:failed
;; These are bugs
122 (should (ert-equal-buffer-return
123 '(find-begs 'bul-beg
)
127 Another normal paragraph
131 (should (ert-equal-buffer-return
132 '(find-begs 'bul-beg
)
143 (ert-deftest rst-convert-bullets-to-enumeration
()
144 "Tests `rst-convert-bullets-to-enumeration'."
145 (should (ert-equal-buffer
146 '(rst-convert-bullets-to-enumeration)
147 "\^@Normal paragraph.
153 Another normal paragraph.
156 "\^@Normal paragraph.
162 Another normal paragraph.
165 (should (ert-equal-buffer
166 '(rst-convert-bullets-to-enumeration)
173 \^@Another normal paragraph.
182 \^@Another normal paragraph.
185 (should (ert-equal-buffer
186 '(rst-convert-bullets-to-enumeration)
197 \^@Another normal paragraph.
211 \^@Another normal paragraph.
216 (ert-deftest rst-convert-bullets-to-enumeration-BUGS
()
217 "Exposes bugs in `rst-convert-bullets-to-enumeration'."
218 :expected-result
:failed
;; These are bugs
219 (should (ert-equal-buffer
220 '(rst-convert-bullets-to-enumeration)
221 "\^@Normal paragraph.
231 Another normal paragraph.
234 "\^@Normal paragraph.
244 Another normal paragraph.
249 (ert-deftest rst-insert-list-continue
()
250 "Tests `rst-insert-list' when continuing a list."
251 (should (ert-equal-buffer
256 (should (ert-equal-buffer
261 (should (ert-equal-buffer
266 (should (ert-equal-buffer
269 - A deeper hyphen bullet\^@\n"
271 - A deeper hyphen bullet
273 (should (ert-equal-buffer
280 (should (ert-equal-buffer
285 (should (ert-equal-buffer
290 (should (ert-equal-buffer
295 (should (ert-equal-buffer
300 (should (ert-equal-buffer
305 (should (ert-equal-buffer
310 (should (ert-equal-buffer
317 (should (ert-equal-buffer
322 (should (ert-equal-buffer
331 (ert-deftest rst-insert-list-continue-BUGS
()
332 "Exposes bugs in `rst-insert-list-continue'."
333 :expected-result
:failed
;; These are bugs
334 (should (ert-equal-buffer
344 (ert-deftest rst-insert-list-new
()
345 "Tests `rst-insert-list' when inserting a new list."
346 (should (ert-equal-buffer
352 (should (ert-equal-buffer
360 (should (ert-equal-buffer
370 (should (ert-equal-buffer
376 (should (ert-equal-buffer
382 (should (ert-equal-buffer
388 (should (ert-equal-buffer
396 (should (ert-equal-buffer
405 (should (ert-equal-buffer
415 (should (ert-equal-buffer
427 (ert-deftest rst-insert-list-new-BUGS
()
428 "Exposes bugs in `rst-insert-list' when inserting a new list."
429 :expected-result
:failed
;; These are bugs
430 (should (ert-equal-buffer
435 (should (ert-equal-buffer
449 (ert-deftest rst-straighten-bullets-region
()
450 "Tests `rst-straighten-bullets-region'."
451 (let ((rst-preferred-bullets '(?
* ?-
)))
452 (should (ert-equal-buffer
453 '(rst-straighten-bullets-region)
457 (should (ert-equal-buffer
458 '(rst-straighten-bullets-region)
470 (should (ert-equal-buffer
471 '(rst-straighten-bullets-region)
477 (should (ert-equal-buffer
478 '(rst-straighten-bullets-region)
490 (should (ert-equal-buffer
491 '(rst-straighten-bullets-region)
507 (should (ert-equal-buffer
508 '(rst-straighten-bullets-region)
524 (should (ert-equal-buffer
525 '(rst-straighten-bullets-region)
542 (let ((rst-preferred-bullets nil
))
543 (should (ert-equal-buffer
544 '(rst-straighten-bullets-region)
558 (ert-deftest rst-straighten-bullets-region-BUGS
()
559 "Tests `rst-straighten-bullets-region'."
560 :expected-result
:failed
;; These are bugs
561 (let ((rst-preferred-bullets '(?
* ?-
)))
562 (should (ert-equal-buffer
563 '(rst-straighten-bullets-region)
575 (should (ert-equal-buffer
576 '(rst-straighten-bullets-region)
588 (should (ert-equal-buffer
589 '(rst-straighten-bullets-region)
603 (defun arabic-roman-roundtrip (arabic roman
)
604 "Convert ARABIC to roman, compare it to ROMAN and convert this back.
605 Return t if roundtrip is correct."
606 (let ((cvt-roman (rst-arabic-to-roman arabic
))
607 (cvt-arabic (rst-roman-to-arabic roman
)))
608 (and (equal roman cvt-roman
) (equal arabic cvt-arabic
))))
610 (ert-deftest arabic-roman-roundtrip
()
611 "Test `rst-arabic-to-roman' and `rst-roman-to-arabic'."
613 ;; Test invalid arabic numbers.
614 (should-error (arabic-roman-roundtrip -
1 "I")
615 :type
'wrong-type-argument
)
616 (should-error (arabic-roman-roundtrip 0 "I")
617 :type
'wrong-type-argument
)
618 (should-error (arabic-roman-roundtrip nil
"I")
619 :type
'wrong-type-argument
)
621 ;; Test invalid roman numbers.
622 (should-error (arabic-roman-roundtrip 1 nil
)
623 :type
'wrong-type-argument
)
624 (should-error (arabic-roman-roundtrip 1 "NoRoman")
625 :type
'wrong-type-argument
)
626 (should-error (arabic-roman-roundtrip 1 "")
627 :type
'wrong-type-argument
)
630 (should (arabic-roman-roundtrip 1 "I"))
631 (should (arabic-roman-roundtrip 4 "IV"))
632 (should (arabic-roman-roundtrip 5 "V"))
633 (should (arabic-roman-roundtrip 10 "X"))
634 (should (arabic-roman-roundtrip 20 "XX"))
635 (should (arabic-roman-roundtrip 1999 "MCMXCIX"))
636 (should (arabic-roman-roundtrip 2000 "MM"))
637 (should (arabic-roman-roundtrip 3333 "MMMCCCXXXIII"))
638 (should (arabic-roman-roundtrip 444 "CDXLIV"))