test-org.el 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;;; test-org.el
  2. ;; Copyright (c) ߚ David Maus
  3. ;; Authors: David Maus
  4. ;; Released under the GNU General Public License version 3
  5. ;; see: http://www.gnu.org/licenses/gpl-3.0.html
  6. ;;;; Comments:
  7. ;; Template test file for Org-mode tests
  8. ;;; Code:
  9. (let* ((testing-lisp-dir (file-name-directory
  10. (or load-file-name buffer-file-name)))
  11. (load-path (cons testing-lisp-dir load-path)))
  12. (dolist (file (directory-files testing-lisp-dir 'full
  13. "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*\\.org$"))
  14. (require (intern (substring file 0 (- (length file) 3))))))
  15. ;;; Tests
  16. (ert-deftest test-org/org-link-escape-ascii-character ()
  17. "Escape an ascii character."
  18. (should
  19. (string=
  20. "%5B"
  21. (org-link-escape "["))))
  22. (ert-deftest test-org/org-link-escape-ascii-ctrl-character ()
  23. "Escape an ascii control character."
  24. (should
  25. (string=
  26. "%09"
  27. (org-link-escape "\t"))))
  28. (ert-deftest test-org/org-link-escape-multibyte-character ()
  29. "Escape an unicode multibyte character."
  30. (should
  31. (string=
  32. "%E2%82%AC"
  33. (org-link-escape "€"))))
  34. (ert-deftest test-org/org-link-escape-custom-table ()
  35. "Escape string with custom character table."
  36. (should
  37. (string=
  38. "Foo%3A%42ar%0A"
  39. (org-link-escape "Foo:Bar\n" '(?\: ?\B)))))
  40. (ert-deftest test-org/org-link-escape-custom-table-merge ()
  41. "Escape string with custom table merged with default table."
  42. (should
  43. (string=
  44. "%5BF%6F%6F%3A%42ar%0A%5D"
  45. (org-link-escape "[Foo:Bar\n]" '(?\: ?\B ?\o) t))))
  46. (ert-deftest test-org/org-link-unescape-ascii-character ()
  47. "Unescape an ascii character."
  48. (should
  49. (string=
  50. "["
  51. (org-link-unescape "%5B"))))
  52. (ert-deftest test-org/org-link-unescape-ascii-ctrl-character ()
  53. "Unescpae an ascii control character."
  54. (should
  55. (string=
  56. "\n"
  57. (org-link-unescape "%0A"))))
  58. (ert-deftest test-org/org-link-unescape-multibyte-character ()
  59. "Unescape unicode multibyte character."
  60. (should
  61. (string=
  62. "€"
  63. (org-link-unescape "%E2%82%AC"))))
  64. (ert-deftest test-org/org-link-unescape-ascii-extended-char ()
  65. "Unescape old style percent escaped character."
  66. (should
  67. (string=
  68. "àâçèéêîôùû"
  69. (decode-coding-string (org-link-unescape "%E0%E2%E7%E8%E9%EA%EE%F4%F9%FB") 'latin-1))))
  70. (ert-deftest test-org/org-link-escape-url-with-escaped-char ()
  71. "Escape and unscape a URL that includes an escaped char.
  72. http://article.gmane.org/gmane.emacs.orgmode/21459/"
  73. (should
  74. (string=
  75. "http://some.host.com/form?&id=blah%2Bblah25"
  76. (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25")))))
  77. (ert-deftest test-org/accumulated-properties-in-drawers ()
  78. "Ensure properties accumulate in subtree drawers."
  79. (org-test-at-id "75282ba2-f77a-4309-a970-e87c149fe125"
  80. (org-babel-next-src-block)
  81. (should (equal '(2 1) (org-babel-execute-src-block)))))
  82. (provide 'test-org)
  83. ;;; test-org.el ends here