test-org-macs.el 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ;;; test-org-macs.el --- Tests for Org Macs library -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2017 Nicolas Goaziou
  3. ;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
  4. ;; This program is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;; You should have received a copy of the GNU General Public License
  13. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. ;;; Code:
  15. (ert-deftest test-org/string-display ()
  16. "Test `org-string-display' specifications."
  17. (should (equal "a" (org-string-display "a")))
  18. (should (equal "" (org-string-display "")))
  19. ;; Ignore invisible characters.
  20. (should (equal "" (org-string-display #("a" 0 1 (invisible t)))))
  21. (should (equal "b" (org-string-display #("ab" 0 1 (invisible t)))))
  22. (should (equal "a" (org-string-display #("ab" 1 2 (invisible t)))))
  23. (should (equal "ace" (org-string-display
  24. #("abcde" 1 2 (invisible t) 3 4 (invisible t)))))
  25. ;; Check if `invisible' value really means invisibility.
  26. (should (equal "" (let ((buffer-invisibility-spec t))
  27. (org-string-display #("a" 0 1 (invisible foo))))))
  28. (should (equal "" (let ((buffer-invisibility-spec '(foo)))
  29. (org-string-display #("a" 0 1 (invisible foo))))))
  30. (should (equal "" (let ((buffer-invisibility-spec '((foo . t))))
  31. (org-string-display #("a" 0 1 (invisible foo))))))
  32. (should (equal "a" (let ((buffer-invisibility-spec '(bar)))
  33. (org-string-display #("a" 0 1 (invisible foo))))))
  34. ;; Check `display' property.
  35. (should (equal "abc" (org-string-display #("a" 0 1 (display "abc")))))
  36. (should (equal "1abc3" (org-string-display #("1a3" 1 2 (display "abc")))))
  37. ;; `display' string can also contain invisible characters.
  38. (should (equal "1ac3" (org-string-display
  39. #("123" 1 2 (display #("abc" 1 2 (invisible t)))))))
  40. ;; Preserve other text properties when replacing with a display
  41. ;; string.
  42. (should
  43. (eq 'foo
  44. (get-text-property 1 'face
  45. (org-string-display
  46. #("123" 1 2 (display "abc" face foo)))))))
  47. (provide 'test-org-macs)
  48. ;;; test-org-macs.el ends here