diff options
| author | Noam Postavsky | 2018-01-26 09:04:47 -0500 |
|---|---|---|
| committer | Noam Postavsky | 2018-01-26 19:50:57 -0500 |
| commit | 81ae9c8c058d17d276a4443f6938aa3b57a40ca4 (patch) | |
| tree | baba5090e02046777cb42ec21e64388351e77ab9 /test | |
| parent | 5a1ee67ae18bf992a7aa77b1b06cfa85950ba458 (diff) | |
| download | emacs-81ae9c8c058d17d276a4443f6938aa3b57a40ca4.tar.gz emacs-81ae9c8c058d17d276a4443f6938aa3b57a40ca4.zip | |
Load mm-util as needed for url-file and url-data (Bug#30258)
* lisp/url/url-file.el (url-file):
* lisp/url/url-misc.el (url-data): Require `mm-util' before calling
`mm-disable-multibyte'.
* test/lisp/url/url-file-resources/file.txt:
* test/lisp/url/url-file-tests.el:
* test/lisp/url/url-misc-tests.el: New tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/url/url-file-resources/file.txt | 1 | ||||
| -rw-r--r-- | test/lisp/url/url-file-tests.el | 50 | ||||
| -rw-r--r-- | test/lisp/url/url-misc-tests.el | 41 |
3 files changed, 92 insertions, 0 deletions
diff --git a/test/lisp/url/url-file-resources/file.txt b/test/lisp/url/url-file-resources/file.txt new file mode 100644 index 00000000000..b0b4e38e5fd --- /dev/null +++ b/test/lisp/url/url-file-resources/file.txt | |||
| @@ -0,0 +1 @@ | |||
| Some file data | |||
diff --git a/test/lisp/url/url-file-tests.el b/test/lisp/url/url-file-tests.el new file mode 100644 index 00000000000..969bca7f8d0 --- /dev/null +++ b/test/lisp/url/url-file-tests.el | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | ;;; url-file-tests.el --- Test suite for url-file. -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2018 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 'url-file) | ||
| 25 | (require 'ert) | ||
| 26 | |||
| 27 | (defconst url-file-tests-data-directory | ||
| 28 | (expand-file-name "lisp/url/url-file-resources" | ||
| 29 | (or (getenv "EMACS_TEST_DIRECTORY") | ||
| 30 | (expand-file-name "../../.." | ||
| 31 | (or load-file-name | ||
| 32 | buffer-file-name)))) | ||
| 33 | "Directory for url-file test files.") | ||
| 34 | |||
| 35 | (ert-deftest url-file () | ||
| 36 | "Test reading file via file:// URL." | ||
| 37 | (let ((file (expand-file-name "file.txt" url-file-tests-data-directory))) | ||
| 38 | (should (equal | ||
| 39 | (with-current-buffer | ||
| 40 | (url-file (url-generic-parse-url (concat "file://" file)) | ||
| 41 | #'ignore nil) | ||
| 42 | (prog1 (buffer-substring (point) (point-max)) | ||
| 43 | (kill-buffer))) | ||
| 44 | (with-temp-buffer | ||
| 45 | (insert-file-contents-literally file) | ||
| 46 | (buffer-string)))))) | ||
| 47 | |||
| 48 | (provide 'url-file-tests) | ||
| 49 | |||
| 50 | ;;; url-file-tests.el ends here | ||
diff --git a/test/lisp/url/url-misc-tests.el b/test/lisp/url/url-misc-tests.el new file mode 100644 index 00000000000..fec2609bb7f --- /dev/null +++ b/test/lisp/url/url-misc-tests.el | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | ;;; url-misc-tests.el --- Test suite for url-misc. -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2018 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 'url-misc) | ||
| 25 | (require 'ert) | ||
| 26 | |||
| 27 | (ert-deftest url-misc-data () | ||
| 28 | "Test reading data: URL." | ||
| 29 | (should (equal | ||
| 30 | (with-current-buffer | ||
| 31 | (url-data (url-generic-parse-url "data:;,some%20text")) | ||
| 32 | (goto-char (point-min)) | ||
| 33 | (forward-paragraph) | ||
| 34 | (forward-line) | ||
| 35 | (prog1 (buffer-substring (point) (point-max)) | ||
| 36 | (kill-buffer))) | ||
| 37 | "some text"))) | ||
| 38 | |||
| 39 | (provide 'url-misc-tests) | ||
| 40 | |||
| 41 | ;;; url-misc-tests.el ends here | ||