Fix Bug#25524
[emacs.git] / test / lisp / ffap-tests.el
blob827d751be699041a22e6e33e7e24b86b10397410
1 ;;; ffap-tests.el --- Test suite for ffap.el -*- lexical-binding: t -*-
3 ;; Copyright (C) 2016-2017 Free Software Foundation, Inc.
5 ;; Author: Tino Calancha <tino.calancha@gmail.com>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
22 ;;; Commentary:
24 ;;; Code:
26 (require 'ert)
27 (require 'ffap)
29 (ert-deftest ffap-tests-25243 ()
30 "Test for http://debbugs.gnu.org/25243 ."
31 (let ((file (make-temp-file "test-Bug#25243")))
32 (unwind-protect
33 (with-temp-file file
34 (let ((str "diff --git b/lisp/ffap.el a/lisp/ffap.el
35 index 3d7cebadcf..ad4b70d737 100644
36 --- b/lisp/ffap.el
37 +++ a/lisp/ffap.el
38 @@ -203,6 +203,9 @@ ffap-foo-at-bar-prefix
39 "))
40 (transient-mark-mode 1)
41 (when (natnump ffap-max-region-length)
42 (insert
43 (concat
44 str
45 (make-string ffap-max-region-length #xa)
46 (format "%s ENDS HERE" file)))
47 (call-interactively 'mark-whole-buffer)
48 (should (equal "" (ffap-string-at-point)))
49 (should (equal '(1 1) ffap-string-at-point-region)))))
50 (and (file-exists-p file) (delete-file file)))))
52 (ert-deftest ffap-gopher-at-point ()
53 (with-temp-buffer
54 (insert "\
55 Type = 1
56 Name = foo
57 Path = /the/path
58 Port = 7070
59 Host = example.com\n")
60 (should-not (ffap-gopher-at-point))
61 (goto-char (point-min))
62 (should (equal (ffap-gopher-at-point)
63 "gopher://example.com:7070/1/the/path"))
64 (should (equal ffap-string-at-point-region
65 (list (point-min) (point-max))))
66 (let ((ffap-gopher-regexp nil))
67 (should-not (ffap-gopher-at-point)))))
69 (provide 'ffap-tests)
71 ;;; ffap-tests.el ends here