;;; test-ol-info.el --- tests for ol-info.el -*- lexical-binding: t; -*- ;; Copyright (C) 2022 Free Software Foundation, Inc. ;; Author: Max Nikulin ;; 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 . ;;; 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