diff options
| author | Lars Ingebrigtsen | 2020-12-29 08:38:17 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-12-29 08:38:25 +0100 |
| commit | ee0e259e5d52749999be329afa9c764a8aff0531 (patch) | |
| tree | d6f411beacac406be31156f95095cd830f2d4fcf /test | |
| parent | 1fc011c07578168ce25f7db2271f58cb02f540a3 (diff) | |
| download | emacs-ee0e259e5d52749999be329afa9c764a8aff0531.tar.gz emacs-ee0e259e5d52749999be329afa9c764a8aff0531.zip | |
Add some tests for align.el
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/align-resources/align-post.c | 3 | ||||
| -rw-r--r-- | test/lisp/align-resources/align-post.java | 9 | ||||
| -rw-r--r-- | test/lisp/align-resources/align-pre.c | 3 | ||||
| -rw-r--r-- | test/lisp/align-resources/align-pre.java | 9 | ||||
| -rw-r--r-- | test/lisp/align-tests.el | 47 |
5 files changed, 71 insertions, 0 deletions
diff --git a/test/lisp/align-resources/align-post.c b/test/lisp/align-resources/align-post.c new file mode 100644 index 00000000000..157e1d6242a --- /dev/null +++ b/test/lisp/align-resources/align-post.c | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | int | ||
| 2 | main (int argc, | ||
| 3 | char *argv[]); | ||
diff --git a/test/lisp/align-resources/align-post.java b/test/lisp/align-resources/align-post.java new file mode 100644 index 00000000000..e0ea8e727f1 --- /dev/null +++ b/test/lisp/align-resources/align-post.java | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | class X | ||
| 2 | { | ||
| 3 | String field1; | ||
| 4 | String[] field2; | ||
| 5 | int field3; | ||
| 6 | int[] field4; | ||
| 7 | X field5; | ||
| 8 | X[] field6; | ||
| 9 | } | ||
diff --git a/test/lisp/align-resources/align-pre.c b/test/lisp/align-resources/align-pre.c new file mode 100644 index 00000000000..b1774181a40 --- /dev/null +++ b/test/lisp/align-resources/align-pre.c | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | int | ||
| 2 | main (int argc, | ||
| 3 | char *argv[]); | ||
diff --git a/test/lisp/align-resources/align-pre.java b/test/lisp/align-resources/align-pre.java new file mode 100644 index 00000000000..fe7a87a9393 --- /dev/null +++ b/test/lisp/align-resources/align-pre.java | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | class X | ||
| 2 | { | ||
| 3 | String field1; | ||
| 4 | String[] field2; | ||
| 5 | int field3; | ||
| 6 | int[] field4; | ||
| 7 | X field5; | ||
| 8 | X[] field6; | ||
| 9 | } | ||
diff --git a/test/lisp/align-tests.el b/test/lisp/align-tests.el new file mode 100644 index 00000000000..b66ebb8b84c --- /dev/null +++ b/test/lisp/align-tests.el | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | ;;; align-tests.el --- Test suite for aligns -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2015-2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert) | ||
| 25 | (require 'ert-x) | ||
| 26 | (require 'align) | ||
| 27 | |||
| 28 | (defun test-align-compare (file function) | ||
| 29 | (should (equal | ||
| 30 | (with-temp-buffer | ||
| 31 | (insert-file-contents (ert-resource-file (format file "pre"))) | ||
| 32 | (funcall function) | ||
| 33 | (align (point-min) (point-max)) | ||
| 34 | (buffer-substring-no-properties (point-min) (point-max))) | ||
| 35 | (with-temp-buffer | ||
| 36 | (insert-file-contents (ert-resource-file (format file "post"))) | ||
| 37 | (buffer-string))))) | ||
| 38 | |||
| 39 | (ert-deftest align-java () | ||
| 40 | (test-align-compare "align-%s.java" #'java-mode)) | ||
| 41 | |||
| 42 | (ert-deftest align-c () | ||
| 43 | (test-align-compare "align-%s.c" #'c-mode)) | ||
| 44 | |||
| 45 | (provide 'align-tests) | ||
| 46 | |||
| 47 | ;;; align-tests.el ends here | ||