1 ;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2016 Google Inc.
5 ;; Author: Philipp Stephani <phst@google.com>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
24 ;; Unit tests for code in src/lread.c.
28 (ert-deftest lread-char-number
()
29 (should (equal ?\N
{U
+A817
} #xA817
)))
31 (ert-deftest lread-char-name
()
32 (should (equal ?\N
{SYLOTI NAGRI LETTER
36 (ert-deftest lread-char-invalid-number
()
37 (should-error (read "?\\N{U+110000}") :type
'invalid-read-syntax
))
39 (ert-deftest lread-char-invalid-name
()
40 (should-error (read "?\\N{DOES NOT EXIST}")) :type
'invalid-read-syntax
)
42 (ert-deftest lread-char-non-ascii-name
()
43 (should-error (read "?\\N{LATIN CAPITAL LETTER Ø}")
44 :type
'invalid-read-syntax
))
46 (ert-deftest lread-char-empty-name
()
47 (should-error (read "?\\N{}") :type
'invalid-read-syntax
))
49 (ert-deftest lread-char-cjk-name
()
50 (should (equal ?\N
{CJK IDEOGRAPH-2B734
} #x2B734
)))
52 (ert-deftest lread-char-invalid-cjk-name
()
53 (should-error (read "?\\N{CJK IDEOGRAPH-2B735}") :type
'invalid-read-syntax
))
55 (ert-deftest lread-string-char-number
()
56 (should (equal "a\N{U+A817}b" "a\uA817b")))
58 (ert-deftest lread-string-char-name
()
59 (should (equal "a\N{SYLOTI NAGRI LETTER DHO}b" "a\uA817b")))
61 ;;; lread-tests.el ends here