aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/coding-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/coding-tests.el')
-rw-r--r--test/src/coding-tests.el58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el
new file mode 100644
index 00000000000..772c8735519
--- /dev/null
+++ b/test/src/coding-tests.el
@@ -0,0 +1,58 @@
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)))
51
52;; See issue #5251.
53(ert-deftest ert-test-unibyte-buffer-dos-eol-decode ()
54 (with-temp-buffer
55 (set-buffer-multibyte nil)
56 (insert (encode-coding-string "あ" 'euc-jp) "\xd" "\n")
57 (decode-coding-region (point-min) (point-max) 'euc-jp-dos)
58 (should-not (string-match-p "\^M" (buffer-string)))))