]> code.delx.au - gnu-emacs/blob - test/src/lread-tests.el
2ebaf491120ff12aa744cade636dd7d27065f941
[gnu-emacs] / test / src / lread-tests.el
1 ;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5 ;; Author: Philipp Stephani <phst@google.com>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; This program 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 ;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;; Unit tests for code in src/lread.c.
25
26 ;;; Code:
27
28 (ert-deftest lread-char-number ()
29 (should (equal (read "?\\N{U+A817}") #xA817)))
30
31 (ert-deftest lread-char-name ()
32 (should (equal (read "?\\N{SYLOTI NAGRI LETTER \n DHO}")
33 #xA817)))
34
35 (ert-deftest lread-char-invalid-number ()
36 (should-error (read "?\\N{U+110000}") :type 'invalid-read-syntax))
37
38 (ert-deftest lread-char-invalid-name ()
39 (should-error (read "?\\N{DOES NOT EXIST}")) :type 'invalid-read-syntax)
40
41 (ert-deftest lread-char-non-ascii-name ()
42 (should-error (read "?\\N{LATIN CAPITAL LETTER Ø}")
43 :type 'invalid-read-syntax))
44
45 (ert-deftest lread-char-empty-name ()
46 (should-error (read "?\\N{}") :type 'invalid-read-syntax))
47
48 (ert-deftest lread-char-surrogate-1 ()
49 (should-error (read "?\\N{U+D800}") :type 'invalid-read-syntax))
50 (ert-deftest lread-char-surrogate-2 ()
51 (should-error (read "?\\N{U+D801}") :type 'invalid-read-syntax))
52 (ert-deftest lread-char-surrogate-3 ()
53 (should-error (read "?\\N{U+Dffe}") :type 'invalid-read-syntax))
54 (ert-deftest lread-char-surrogate-4 ()
55 (should-error (read "?\\N{U+DFFF}") :type 'invalid-read-syntax))
56
57 (ert-deftest lread-string-char-number-1 ()
58 (should (equal (read "a\\N{U+A817}b") "a\uA817bx")))
59 (ert-deftest lread-string-char-number-2 ()
60 (should-error (read "?\\N{0.5}") :type 'invalid-read-syntax))
61 (ert-deftest lread-string-char-number-3 ()
62 (should-error (read "?\\N{U+-0}") :type 'invalid-read-syntax))
63
64 (ert-deftest lread-string-char-name ()
65 (should (equal (read "a\\N{SYLOTI NAGRI LETTER DHO}b") "a\uA817b")))
66
67 ;;; lread-tests.el ends here