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