1 ;;; cc-mode-tests.el --- Test suite for cc-mode. -*- lexical-binning: t -*-
3 ;; Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
30 (ert-deftest c-or-c++-mode ()
31 "Test c-or-c++-mode language detection."
33 (do-test (lambda (content expected)
34 (delete-region (point-min) (point-max))
38 (unless(eq expected mode)
40 (format "expected %s but got %s when testing '%s'"
41 expected mode content)))))
42 ((symbol-function 'c-mode) (lambda () (setq mode 'c-mode)))
43 ((symbol-function 'c++-mode) (lambda () (setq mode 'c++-mode))))
45 (mapc (lambda (content)
46 (funcall do-test content 'c++-mode)
47 (funcall do-test (concat "// " content) 'c-mode)
48 (funcall do-test (concat " * " content) 'c-mode))
49 '("using \t namespace \t std;"
50 "using \t std::string;"
52 "namespace \t foo \t {"
53 "class \t Blah_42 \t {"
54 "class \t Blah_42 \t \n"
55 "class \t _42_Blah:public Foo {"
56 "template \t < class T >"
62 (mapc (lambda (content) (funcall do-test content 'c-mode))
63 '("struct \t Blah_42 \t {"
65 "#include <string.h>")))))