test-org.el 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. (provide 'test-org)
  78. ;;; test-org.el ends here