]> code.delx.au - gnu-emacs-elpa/blob - packages/load-relative/test/test-file.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / load-relative / test / test-file.el
1 ;;; test-file.el --- Simple test for load-relative
2
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
4
5 ;; This program is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
17
18 ;;; Commentary:
19
20 ;;; Code:
21
22 (load-file "../load-relative.el")
23
24 (require 'ert)
25
26
27 (ert-deftest test-name ()
28 (should
29 ;; not sure how I can test the full path here because, well, I need to
30 ;; resolve a relative path to do so...
31 (equal
32 "simple.txt"
33 (let ((bf
34 (find-file-noselect-relative "simple.txt")))
35 (kill-buffer bf)
36 (file-name-nondirectory
37 (buffer-file-name bf))))))
38
39 (ert-deftest test-contents ()
40 (should
41 (equal
42 "simple\n"
43 (let* ((bf
44 (find-file-noselect-relative "simple.txt"))
45 (ct
46 (with-current-buffer
47 bf
48 (buffer-string))))
49 (kill-buffer bf)
50 ct))))
51
52 (ert-deftest test-contents-with-relative-file ()
53 (should
54 (equal
55 "simple\n"
56 (with-relative-file
57 "simple.txt"
58 (buffer-string)))))
59
60 (provide 'test-file)
61
62 ;;; test-file.el ends here