1 ;;; cc-mode-tests.el --- Test suite for cc-mode. -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
5 ;; Author: Michal Nazarewicz <mina86@mina86.com>
7 ;; Human-Keywords: internal
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
27 ;; Unit tests for cc-mode.el.
35 (ert-deftest c-or-c
++-mode
()
36 "Test c-or-c++-mode language detection."
38 (do-test (lambda (content expected
)
39 (delete-region (point-min) (point-max))
43 (unless(eq expected mode
)
45 (format "expected %s but got %s when testing '%s'"
46 expected mode content
)))))
47 ((symbol-function 'c-mode
) (lambda () (setq mode
'c-mode
)))
48 ((symbol-function 'c
++-mode
) (lambda () (setq mode
'c
++-mode
))))
50 (mapc (lambda (content)
51 (funcall do-test content
'c
++-mode
)
52 (funcall do-test
(concat "// " content
) 'c-mode
)
53 (funcall do-test
(concat " * " content
) 'c-mode
))
54 '("using \t namespace \t std;"
55 "using \t std::string;"
57 "namespace \t foo \t {"
58 "class \t Blah_42 \t {"
59 "class \t Blah_42 \t \n"
60 "class \t _42_Blah:public Foo {"
61 "template \t < class T >"
67 (mapc (lambda (content) (funcall do-test content
'c-mode
))
68 '("struct \t Blah_42 \t {"
70 "#include <string.h>")))))
72 (ert-deftest c-mode-macro-comment
()
74 (dolist (macro-string '("#define /***/f"
76 "#define a(x)get/***/x/***/id())"))
81 ;;; cc-mode-tests.el ends here