emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob aa5234260eb2b068fe9cc26c5ad825ac89496d40 3912 bytes (raw)
name: testing/lisp/test-ol-info.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
;;; test-ol-info.el --- tests for ol-info.el                        -*- lexical-binding: t; -*-

;; Copyright (C) 2022 Free Software Foundation, Inc.

;; Author:  Max Nikulin <manikulin@gmail.com>
;; Keywords: org, texinfo

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; Test some functions from ol-info.el.

;;; Code:

(unless (featurep 'ol-info)
  (signal 'missing-test-dependency "Support for info links"))

(ert-deftest test-org-link-info/link-file-node ()
  "Test parse info links by `org-info-link-file-node'."
  (should (equal '("success" "Double Colon Separator")
                 (org-info-link-file-node "success::Double Colon Separator")))
  (should (equal '("success" "Hash Separator")
                 (org-info-link-file-node "success#Hash Separator")))
  (should (equal '("nodeless" "Top")
                 (org-info-link-file-node "nodeless")))
  (should (equal '("trailing-hash" "Top")
                 (org-info-link-file-node "trailing-hash#")))
  (should (equal '("trailing-double-colon" "Top")
                 (org-info-link-file-node "trailing-double-colon")))
  (should (equal '("with-scheme" "Double Colon Separator")
                 (org-info-link-file-node "info:with-scheme::Double Colon Separator")))
  (should (equal '("with-scheme" "Hash Separator")
                 (org-info-link-file-node "info:with-scheme#Hash Separator")))
  (should (equal '("scheme-and-file" "Top")
                 (org-info-link-file-node "info:scheme-and-file")))
  (should (equal '("scheme-file-hash" "Top")
                 (org-info-link-file-node "info:scheme-file-hash#")))
  (should (equal '("scheme-file-double-colon" "Top")
                 (org-info-link-file-node "info:scheme-file-double-colon")))
  (should (eq nil (org-info-link-file-node nil)))
  (should (eq nil (org-info-link-file-node "Info:broken#Wrong scheme case")))
  (should (eq nil (org-info-link-file-node "http:broken::Not info scheme"))))

(ert-deftest test-org-link-info/description-as-command ()
  "Test `org-info-description-as-command'."
  (let ((cases
         '(("info file" "file")
           ("info strip-top" "strip-top#Top")
           ("info strip-top-hash" "info:strip-top-hash#Top")
           ("info strip-top-double-colon" "strip-top-double-colon::Top")
           ("info \"(pass) Hash\"" "pass#Hash")
           ("info \"(pass) Double Colon\"" "info:pass#Double Colon")
           (nil nil)
           (nil "https://wrong.scheme"))))
    (dolist (expectation-input cases)
      (let ((expectation (car expectation-input))
            (input (cadr expectation-input)))
        (should (equal
                 expectation
                 (org-info-description-as-command input nil))))))
  (let ((cases
         '(("Override link" "ignored#Link" "Override link")
           ("Fallback description" "http://not.info/link" "Fallback description")
           ("Link is nil" nil "Link is nil")
           (nil nil nil))))
        (dolist (expectation-input-desc cases)
      (let ((expectation (car expectation-input-desc))
            (input (cadr expectation-input-desc))
            (desc (nth 2 expectation-input-desc)))
        (should (equal
                 expectation
                 (org-info-description-as-command input desc)))))))

(provide 'test-ol-info)
;;; test-ol-info.el ends here

debug log:

solving aa5234260 ...
found aa5234260 in https://list.orgmode.org/orgmode/8bbccdb4-52f4-b9b5-eb10-252bb15108ec@gmail.com/

applying [1/1] https://list.orgmode.org/orgmode/8bbccdb4-52f4-b9b5-eb10-252bb15108ec@gmail.com/
diff --git a/testing/lisp/test-ol-info.el b/testing/lisp/test-ol-info.el
new file mode 100644
index 000000000..aa5234260

Checking patch testing/lisp/test-ol-info.el...
Applied patch testing/lisp/test-ol-info.el cleanly.

index at:
100644 aa5234260eb2b068fe9cc26c5ad825ac89496d40	testing/lisp/test-ol-info.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).