1 ;;; clang-include-fixer-test.el --- unit tests for clang-include-fixer.el -*- lexical-binding: t; -*-
5 ;; Unit tests for clang-include-fixer.el.
9 (require 'clang-include-fixer
)
14 (ert-deftest clang-include-fixer--insert-line
()
15 "Unit test for `clang-include-fixer--insert-line'."
17 (insert "aa\nab\nac\nad\n")
18 (let ((from (current-buffer)))
20 (insert "aa\nac\nad\n")
21 (let ((to (current-buffer)))
22 (should (clang-include-fixer--insert-line from to
))
23 (should (equal (buffer-string) "aa\nab\nac\nad\n")))))
24 (should (equal (buffer-string) "aa\nab\nac\nad\n"))))
26 (ert-deftest clang-include-fixer--insert-line-diff-on-empty-line
()
27 "Unit test for `clang-include-fixer--insert-line'."
29 (insert "aa\nab\n\nac\nad\n")
30 (let ((from (current-buffer)))
32 (insert "aa\n\nac\nad\n")
33 (let ((to (current-buffer)))
34 (should (clang-include-fixer--insert-line from to
))
35 (should (equal (buffer-string) "aa\nab\n\nac\nad\n")))))
36 (should (equal (buffer-string) "aa\nab\n\nac\nad\n"))))
38 (ert-deftest clang-include-fixer--symbol-at-point
()
39 "Unit test for `clang-include-fixer--symbol-at-point'."
43 (goto-char (point-min))
44 (should (equal (clang-include-fixer--symbol-at-point) "a"))
46 ;; Emacs treats the character immediately following a symbol as part of the
48 (should (equal (clang-include-fixer--symbol-at-point) "a"))
50 (should (equal (clang-include-fixer--symbol-at-point) "bbb::cc"))
51 (goto-char (point-max))
52 (should (equal (clang-include-fixer--symbol-at-point) "bbb::cc"))))
54 (ert-deftest clang-include-fixer--highlight
()
56 (insert "util::Status foo;\n")
57 (setq buffer-file-coding-system
'utf-8-unix
)
58 (should (equal nil
(clang-include-fixer--highlight
59 '((Range .
((Offset .
0) (Length .
0)))))))
60 (let ((overlay (clang-include-fixer--highlight
61 '((Range .
((Offset .
1) (Length .
12)))))))
62 (should (equal 2 (overlay-start overlay
)))
63 (should (equal 14 (overlay-end overlay
))))))
65 ;;; clang-include-fixer-test.el ends here