]> code.delx.au - gnu-emacs/blob - test/lisp/legacy/coding-tests.el
cba8c7bc25f00283989d9965de6a2f9e61753b4c
[gnu-emacs] / test / lisp / legacy / coding-tests.el
1 ;;; coding-tests.el --- tests for text encoding and decoding
2
3 ;; Copyright (C) 2015-2016 Free Software Foundation, Inc.
4
5 ;; Author: Eli Zaretskii <eliz@gnu.org>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Code:
23
24 (require 'ert)
25
26 ;; Directory to hold test data files.
27 (defvar coding-tests-workdir
28 (expand-file-name "coding-tests" temporary-file-directory))
29
30 ;; Remove all generated test files.
31 (defun coding-tests-remove-files ()
32 (delete-directory coding-tests-workdir t))
33
34 (ert-deftest ert-test-coding-bogus-coding-systems ()
35 (unwind-protect
36 (let (test-file)
37 (or (file-directory-p coding-tests-workdir)
38 (mkdir coding-tests-workdir t))
39 (setq test-file (expand-file-name "nonexistent" coding-tests-workdir))
40 (if (file-exists-p test-file)
41 (delete-file test-file))
42 (should-error
43 (let ((coding-system-for-read 'bogus))
44 (insert-file-contents test-file)))
45 ;; See bug #21602.
46 (setq test-file (expand-file-name "writing" coding-tests-workdir))
47 (should-error
48 (let ((coding-system-for-write (intern "\"us-ascii\"")))
49 (write-region "some text" nil test-file))))
50 (coding-tests-remove-files)))