New functions for paragraph-like navigation
[org-mode.git] / testing / lisp / test-org.el
blobb6c5558a8927cde23d600d1c170ed4d370c05480
1 ;;; test-org.el --- tests for org.el
3 ;; Copyright (c) David Maus
4 ;; Authors: David Maus
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ;;; Comments:
23 ;; Template test file for Org-mode tests
25 ;;; Code:
28 ;;; Comments
30 (ert-deftest test-org/comment-dwim ()
31 "Test `comment-dwim' behaviour in an Org buffer."
32 ;; No region selected, no comment on current line and line not
33 ;; empty: insert comment on line above.
34 (should
35 (equal "# \nComment"
36 (org-test-with-temp-text "Comment"
37 (progn (call-interactively 'comment-dwim)
38 (buffer-string)))))
39 ;; No region selected, no comment on current line and line empty:
40 ;; insert comment on this line.
41 (should
42 (equal "# \nParagraph"
43 (org-test-with-temp-text "\nParagraph"
44 (progn (call-interactively 'comment-dwim)
45 (buffer-string)))))
46 ;; No region selected, and a comment on this line: indent it.
47 (should
48 (equal "* Headline\n # Comment"
49 (org-test-with-temp-text "* Headline\n# Comment"
50 (progn (forward-line)
51 (let ((org-adapt-indentation t))
52 (call-interactively 'comment-dwim))
53 (buffer-string)))))
54 ;; Also recognize single # at column 0 as comments.
55 (should
56 (equal "# Comment"
57 (org-test-with-temp-text "# Comment"
58 (progn (forward-line)
59 (call-interactively 'comment-dwim)
60 (buffer-string)))))
61 ;; Region selected and only comments and blank lines within it:
62 ;; un-comment all commented lines.
63 (should
64 (equal "Comment 1\n\nComment 2"
65 (org-test-with-temp-text "# Comment 1\n\n# Comment 2"
66 (progn
67 (transient-mark-mode 1)
68 (push-mark (point) t t)
69 (goto-char (point-max))
70 (call-interactively 'comment-dwim)
71 (buffer-string)))))
72 ;; Region selected without comments: comment all lines if
73 ;; `comment-empty-lines' is non-nil, only non-blank lines otherwise.
74 (should
75 (equal "# Comment 1\n\n# Comment 2"
76 (org-test-with-temp-text "Comment 1\n\nComment 2"
77 (progn
78 (transient-mark-mode 1)
79 (push-mark (point) t t)
80 (goto-char (point-max))
81 (let ((comment-empty-lines nil))
82 (call-interactively 'comment-dwim))
83 (buffer-string)))))
84 (should
85 (equal "# Comment 1\n# \n# Comment 2"
86 (org-test-with-temp-text "Comment 1\n\nComment 2"
87 (progn
88 (transient-mark-mode 1)
89 (push-mark (point) t t)
90 (goto-char (point-max))
91 (let ((comment-empty-lines t))
92 (call-interactively 'comment-dwim))
93 (buffer-string)))))
94 ;; In front of a keyword without region, insert a new comment.
95 (should
96 (equal "# \n#+KEYWORD: value"
97 (org-test-with-temp-text "#+KEYWORD: value"
98 (progn (call-interactively 'comment-dwim)
99 (buffer-string))))))
103 ;;; Date and time analysis
105 (ert-deftest test-org/org-read-date ()
106 "Test `org-read-date' specifications."
107 ;; Parse ISO date with abbreviated year and month.
108 (should (equal "2012-03-29 16:40"
109 (let ((org-time-was-given t))
110 (org-read-date t nil "12-3-29 16:40"))))
111 ;; Parse Europeans dates.
112 (should (equal "2012-03-29 16:40"
113 (let ((org-time-was-given t))
114 (org-read-date t nil "29.03.2012 16:40"))))
115 ;; Parse Europeans dates without year.
116 (should (string-match "2[0-9]\\{3\\}-03-29 16:40"
117 (let ((org-time-was-given t))
118 (org-read-date t nil "29.03. 16:40")))))
120 (ert-deftest test-org/org-parse-time-string ()
121 "Test `org-parse-time-string'."
122 (should (equal (org-parse-time-string "2012-03-29 16:40")
123 '(0 40 16 29 3 2012 nil nil nil)))
124 (should (equal (org-parse-time-string "[2012-03-29 16:40]")
125 '(0 40 16 29 3 2012 nil nil nil)))
126 (should (equal (org-parse-time-string "<2012-03-29 16:40>")
127 '(0 40 16 29 3 2012 nil nil nil)))
128 (should (equal (org-parse-time-string "<2012-03-29>")
129 '(0 0 0 29 3 2012 nil nil nil)))
130 (should (equal (org-parse-time-string "<2012-03-29>" t)
131 '(0 nil nil 29 3 2012 nil nil nil))))
134 ;;; Filling
136 (ert-deftest test-org/fill-paragraph ()
137 "Test `org-fill-paragraph' specifications."
138 ;; At an Org table, align it.
139 (should
140 (equal "| a |\n"
141 (org-test-with-temp-text "|a|"
142 (org-fill-paragraph)
143 (buffer-string))))
144 (should
145 (equal "#+name: table\n| a |\n"
146 (org-test-with-temp-text "#+name: table\n| a |"
147 (org-fill-paragraph)
148 (buffer-string))))
149 ;; At a paragraph, preserve line breaks.
150 (org-test-with-temp-text "some \\\\\nlong\ntext"
151 (let ((fill-column 20))
152 (org-fill-paragraph)
153 (should (equal (buffer-string) "some \\\\\nlong text"))))
154 ;; Correctly fill a paragraph when point is at its very end.
155 (should
156 (equal "A B"
157 (org-test-with-temp-text "A\nB"
158 (let ((fill-column 20))
159 (goto-char (point-max))
160 (org-fill-paragraph)
161 (buffer-string)))))
162 ;; Correctly fill the last paragraph of a greater element.
163 (should
164 (equal "#+BEGIN_CENTER\n- 012345\n 789\n#+END_CENTER"
165 (org-test-with-temp-text "#+BEGIN_CENTER\n- 012345 789\n#+END_CENTER"
166 (let ((fill-column 8))
167 (forward-line)
168 (end-of-line)
169 (org-fill-paragraph)
170 (buffer-string)))))
171 ;; Correctly fill an element in a narrowed buffer.
172 (should
173 (equal "01234\n6"
174 (org-test-with-temp-text "01234 6789"
175 (let ((fill-column 5))
176 (narrow-to-region 1 8)
177 (org-fill-paragraph)
178 (buffer-string)))))
179 ;; Handle `adaptive-fill-regexp' in paragraphs.
180 (should
181 (equal "> a b"
182 (org-test-with-temp-text "> a\n> b"
183 (let ((fill-column 5)
184 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
185 (org-fill-paragraph)
186 (buffer-string)))))
187 ;; Special case: Fill first paragraph when point is at an item or
188 ;; a plain-list or a footnote reference.
189 (should
190 (equal "- A B"
191 (org-test-with-temp-text "- A\n B"
192 (let ((fill-column 20))
193 (org-fill-paragraph)
194 (buffer-string)))))
195 (should
196 (equal "[fn:1] A B"
197 (org-test-with-temp-text "[fn:1] A\nB"
198 (let ((fill-column 20))
199 (org-fill-paragraph)
200 (buffer-string)))))
201 (org-test-with-temp-text "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"
202 (let ((fill-column 20))
203 (org-fill-paragraph)
204 (should (equal (buffer-string)
205 "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"))))
206 ;; Fill contents of `comment-block' elements.
207 (should
208 (equal
209 (org-test-with-temp-text "#+BEGIN_COMMENT\nSome\ntext\n#+END_COMMENT"
210 (let ((fill-column 20))
211 (forward-line)
212 (org-fill-paragraph)
213 (buffer-string)))
214 "#+BEGIN_COMMENT\nSome text\n#+END_COMMENT"))
215 ;; Fill `comment' elements.
216 (should
217 (equal " # A B"
218 (org-test-with-temp-text " # A\n # B"
219 (let ((fill-column 20))
220 (org-fill-paragraph)
221 (buffer-string)))))
222 ;; Do not mix consecutive comments when filling one of them.
223 (should
224 (equal "# A B\n\n# C"
225 (org-test-with-temp-text "# A\n# B\n\n# C"
226 (let ((fill-column 20))
227 (org-fill-paragraph)
228 (buffer-string)))))
229 ;; Use commented empty lines as separators when filling comments.
230 (should
231 (equal "# A B\n#\n# C"
232 (org-test-with-temp-text "# A\n# B\n#\n# C"
233 (let ((fill-column 20))
234 (org-fill-paragraph)
235 (buffer-string)))))
236 ;; Handle `adaptive-fill-regexp' in comments.
237 (should
238 (equal "# > a b"
239 (org-test-with-temp-text "# > a\n# > b"
240 (let ((fill-column 20)
241 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
242 (org-fill-paragraph)
243 (buffer-string)))))
244 ;; Do nothing at affiliated keywords.
245 (org-test-with-temp-text "#+NAME: para\nSome\ntext."
246 (let ((fill-column 20))
247 (org-fill-paragraph)
248 (should (equal (buffer-string) "#+NAME: para\nSome\ntext."))))
249 ;; Do not move point after table when filling a table.
250 (should-not
251 (org-test-with-temp-text "| a | b |\n| c | d |\n"
252 (forward-char)
253 (org-fill-paragraph)
254 (eobp))))
256 (ert-deftest test-org/auto-fill-function ()
257 "Test auto-filling features."
258 ;; Auto fill paragraph.
259 (should
260 (equal "12345\n7890"
261 (org-test-with-temp-text "12345 7890"
262 (let ((fill-column 5))
263 (end-of-line)
264 (org-auto-fill-function)
265 (buffer-string)))))
266 ;; Auto fill first paragraph in an item.
267 (should
268 (equal "- 12345\n 7890"
269 (org-test-with-temp-text "- 12345 7890"
270 (let ((fill-column 7))
271 (end-of-line)
272 (org-auto-fill-function)
273 (buffer-string)))))
274 ;; Auto fill paragraph when `adaptive-fill-regexp' matches.
275 (should
276 (equal "> 12345\n 7890"
277 (org-test-with-temp-text "> 12345 7890"
278 (let ((fill-column 10)
279 (adaptive-fill-regexp "[ \t]*>+[ \t]*")
280 (adaptive-fill-first-line-regexp "\\`[ ]*\\'"))
281 (end-of-line)
282 (org-auto-fill-function)
283 (buffer-string)))))
284 (should
285 (equal "> 12345\n> 12345\n> 7890"
286 (org-test-with-temp-text "> 12345\n> 12345 7890"
287 (let ((fill-column 10)
288 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
289 (goto-char (point-max))
290 (org-auto-fill-function)
291 (buffer-string)))))
292 (should-not
293 (equal " 12345\n *12345\n *12345"
294 (org-test-with-temp-text " 12345\n *12345 12345"
295 (let ((fill-column 10)
296 (adaptive-fill-regexp "[ \t]*>+[ \t]*"))
297 (goto-char (point-max))
298 (org-auto-fill-function)
299 (buffer-string)))))
300 ;; Auto fill comments.
301 (should
302 (equal " # 12345\n # 7890"
303 (org-test-with-temp-text " # 12345 7890"
304 (let ((fill-column 10))
305 (end-of-line)
306 (org-auto-fill-function)
307 (buffer-string)))))
308 ;; A hash within a line isn't a comment.
309 (should-not
310 (equal "12345 # 7890\n# 1"
311 (org-test-with-temp-text "12345 # 7890 1"
312 (let ((fill-column 12))
313 (end-of-line)
314 (org-auto-fill-function)
315 (buffer-string)))))
316 ;; Correctly interpret empty prefix.
317 (should-not
318 (equal "# a\n# b\nRegular\n# paragraph"
319 (org-test-with-temp-text "# a\n# b\nRegular paragraph"
320 (let ((fill-column 12))
321 (end-of-line 3)
322 (org-auto-fill-function)
323 (buffer-string)))))
324 ;; Comment block: auto fill contents.
325 (should
326 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
327 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
328 (let ((fill-column 5))
329 (forward-line)
330 (end-of-line)
331 (org-auto-fill-function)
332 (buffer-string)))))
333 (should
334 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
335 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
336 (let ((fill-column 5))
337 (forward-line)
338 (end-of-line)
339 (org-auto-fill-function)
340 (buffer-string)))))
341 ;; Do not fill if a new item could be created.
342 (should-not
343 (equal "12345\n- 90"
344 (org-test-with-temp-text "12345 - 90"
345 (let ((fill-column 5))
346 (end-of-line)
347 (org-auto-fill-function)
348 (buffer-string)))))
349 ;; Do not fill if a line break could be introduced.
350 (should-not
351 (equal "123\\\\\n7890"
352 (org-test-with-temp-text "123\\\\ 7890"
353 (let ((fill-column 6))
354 (end-of-line)
355 (org-auto-fill-function)
356 (buffer-string)))))
357 ;; Do not fill affiliated keywords.
358 (should-not
359 (equal "#+ATTR_LATEX: ABC\nDEFGHIJKL"
360 (org-test-with-temp-text "#+ATTR_LATEX: ABC DEFGHIJKL"
361 (let ((fill-column 20))
362 (end-of-line)
363 (org-auto-fill-function)
364 (buffer-string))))))
368 ;;; Editing
370 ;;;; Insert elements
372 (ert-deftest test-org/meta-return ()
373 "Test M-RET (`org-meta-return')."
374 ;; In a table field insert a row above.
375 (should
376 (org-test-with-temp-text "| a |"
377 (forward-char)
378 (org-meta-return)
379 (forward-line -1)
380 (looking-at "| |$")))
381 ;; In a paragraph change current line into a header.
382 (should
383 (org-test-with-temp-text "a"
384 (org-meta-return)
385 (beginning-of-line)
386 (looking-at "\* a$")))
387 ;; In an item insert an item, in this case above.
388 (should
389 (org-test-with-temp-text "- a"
390 (org-meta-return)
391 (beginning-of-line)
392 (looking-at "- $")))
393 ;; In a drawer and paragraph insert an empty line, in this case above.
394 (should
395 (let ((org-drawers '("MYDRAWER")))
396 (org-test-with-temp-text ":MYDRAWER:\na\n:END:"
397 (forward-line)
398 (org-meta-return)
399 (forward-line -1)
400 (looking-at "$"))))
401 ;; In a drawer and item insert an item, in this case above.
402 (should
403 (let ((org-drawers '("MYDRAWER")))
404 (org-test-with-temp-text ":MYDRAWER:\n- a\n:END:"
405 (forward-line)
406 (org-meta-return)
407 (beginning-of-line)
408 (looking-at "- $")))))
413 ;;; Links
415 ;;;; Fuzzy Links
417 ;; Fuzzy links [[text]] encompass links to a target (<<text>>), to
418 ;; a named element (#+name: text) and to headlines (* Text).
420 (ert-deftest test-org/fuzzy-links ()
421 "Test fuzzy links specifications."
422 ;; 1. Fuzzy link goes in priority to a matching target.
423 (should
424 (org-test-with-temp-text "#+NAME: Test\n|a|b|\n<<Test>>\n* Test\n[[Test]]"
425 (goto-line 5)
426 (org-open-at-point)
427 (looking-at "<<Test>>")))
428 ;; 2. Then fuzzy link points to an element with a given name.
429 (should
430 (org-test-with-temp-text "Test\n#+NAME: Test\n|a|b|\n* Test\n[[Test]]"
431 (goto-line 5)
432 (org-open-at-point)
433 (looking-at "#\\+NAME: Test")))
434 ;; 3. A target still lead to a matching headline otherwise.
435 (should
436 (org-test-with-temp-text "* Head1\n* Head2\n*Head3\n[[Head2]]"
437 (goto-line 4)
438 (org-open-at-point)
439 (looking-at "\\* Head2")))
440 ;; 4. With a leading star in link, enforce heading match.
441 (should
442 (org-test-with-temp-text "* Test\n<<Test>>\n[[*Test]]"
443 (goto-line 3)
444 (org-open-at-point)
445 (looking-at "\\* Test"))))
448 ;;;; Link Escaping
450 (ert-deftest test-org/org-link-escape-ascii-character ()
451 "Escape an ascii character."
452 (should
453 (string=
454 "%5B"
455 (org-link-escape "["))))
457 (ert-deftest test-org/org-link-escape-ascii-ctrl-character ()
458 "Escape an ascii control character."
459 (should
460 (string=
461 "%09"
462 (org-link-escape "\t"))))
464 (ert-deftest test-org/org-link-escape-multibyte-character ()
465 "Escape an unicode multibyte character."
466 (should
467 (string=
468 "%E2%82%AC"
469 (org-link-escape "€"))))
471 (ert-deftest test-org/org-link-escape-custom-table ()
472 "Escape string with custom character table."
473 (should
474 (string=
475 "Foo%3A%42ar%0A"
476 (org-link-escape "Foo:Bar\n" '(?\: ?\B)))))
478 (ert-deftest test-org/org-link-escape-custom-table-merge ()
479 "Escape string with custom table merged with default table."
480 (should
481 (string=
482 "%5BF%6F%6F%3A%42ar%0A%5D"
483 (org-link-escape "[Foo:Bar\n]" '(?\: ?\B ?\o) t))))
485 (ert-deftest test-org/org-link-unescape-ascii-character ()
486 "Unescape an ascii character."
487 (should
488 (string=
490 (org-link-unescape "%5B"))))
492 (ert-deftest test-org/org-link-unescape-ascii-ctrl-character ()
493 "Unescpae an ascii control character."
494 (should
495 (string=
496 "\n"
497 (org-link-unescape "%0A"))))
499 (ert-deftest test-org/org-link-unescape-multibyte-character ()
500 "Unescape unicode multibyte character."
501 (should
502 (string=
503 "€"
504 (org-link-unescape "%E2%82%AC"))))
506 (ert-deftest test-org/org-link-unescape-ascii-extended-char ()
507 "Unescape old style percent escaped character."
508 (should
509 (string=
510 "àâçèéêîôùû"
511 (decode-coding-string
512 (org-link-unescape "%E0%E2%E7%E8%E9%EA%EE%F4%F9%FB") 'latin-1))))
514 (ert-deftest test-org/org-link-escape-url-with-escaped-char ()
515 "Escape and unescape a URL that includes an escaped char.
516 http://article.gmane.org/gmane.emacs.orgmode/21459/"
517 (should
518 (string=
519 "http://some.host.com/form?&id=blah%2Bblah25"
520 (org-link-unescape
521 (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25")))))
523 (ert-deftest test-org/org-link-escape-chars-browser ()
524 "Escape a URL to pass to `browse-url'."
525 (should
526 (string=
527 "http://some.host.com/search?q=%22Org%20mode%22"
528 (org-link-escape "http://some.host.com/search?q=\"Org mode\""
529 org-link-escape-chars-browser))))
533 ;;; Node Properties
535 (ert-deftest test-org/accumulated-properties-in-drawers ()
536 "Ensure properties accumulate in subtree drawers."
537 (org-test-at-id "75282ba2-f77a-4309-a970-e87c149fe125"
538 (org-babel-next-src-block)
539 (should (equal '(2 1) (org-babel-execute-src-block)))))
543 ;;; Mark Region
545 (ert-deftest test-org/mark-subtree ()
546 "Test `org-mark-subtree' specifications."
547 ;; Error when point is before first headline.
548 (should-error
549 (org-test-with-temp-text "Paragraph\n* Headline\nBody"
550 (progn (transient-mark-mode 1)
551 (org-mark-subtree))))
552 ;; Without argument, mark current subtree.
553 (should
554 (equal
555 '(12 32)
556 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
557 (progn (transient-mark-mode 1)
558 (forward-line 2)
559 (org-mark-subtree)
560 (list (region-beginning) (region-end))))))
561 ;; With an argument, move ARG up.
562 (should
563 (equal
564 '(1 32)
565 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
566 (progn (transient-mark-mode 1)
567 (forward-line 2)
568 (org-mark-subtree 1)
569 (list (region-beginning) (region-end))))))
570 ;; Do not get fooled by inlinetasks.
571 (when (featurep 'org-inlinetask)
572 (should
573 (= 1
574 (org-test-with-temp-text "* Headline\n*************** Task\nContents"
575 (progn (transient-mark-mode 1)
576 (forward-line 1)
577 (let ((org-inlinetask-min-level 15)) (org-mark-subtree))
578 (region-beginning)))))))
582 ;;; Navigation
584 (ert-deftest test-org/beginning-of-line ()
585 "Test `org-beginning-of-line' specifications."
586 ;; Standard test.
587 (should
588 (org-test-with-temp-text "Some text\nSome other text"
589 (progn (org-beginning-of-line) (bolp))))
590 ;; Standard test with `visual-line-mode'.
591 (should-not
592 (org-test-with-temp-text "A long line of text\nSome other text"
593 (progn (visual-line-mode)
594 (forward-char 2)
595 (dotimes (i 1000) (insert "very "))
596 (org-beginning-of-line)
597 (bolp))))
598 ;; At an headline with special movement.
599 (should
600 (org-test-with-temp-text "* TODO Headline"
601 (let ((org-special-ctrl-a/e t))
602 (org-end-of-line)
603 (and (progn (org-beginning-of-line) (looking-at "Headline"))
604 (progn (org-beginning-of-line) (bolp))
605 (progn (org-beginning-of-line) (looking-at "Headline")))))))
607 (ert-deftest test-org/end-of-line ()
608 "Test `org-end-of-line' specifications."
609 ;; Standard test.
610 (should
611 (org-test-with-temp-text "Some text\nSome other text"
612 (progn (org-end-of-line) (eolp))))
613 ;; Standard test with `visual-line-mode'.
614 (should-not
615 (org-test-with-temp-text "A long line of text\nSome other text"
616 (progn (visual-line-mode)
617 (forward-char 2)
618 (dotimes (i 1000) (insert "very "))
619 (goto-char (point-min))
620 (org-end-of-line)
621 (eolp))))
622 ;; At an headline with special movement.
623 (should
624 (org-test-with-temp-text "* Headline1 :tag:\n"
625 (let ((org-special-ctrl-a/e t))
626 (and (progn (org-end-of-line) (looking-at " :tag:"))
627 (progn (org-end-of-line) (eolp))
628 (progn (org-end-of-line) (looking-at " :tag:"))))))
629 ;; At an headline without special movement.
630 (should
631 (org-test-with-temp-text "* Headline2 :tag:\n"
632 (let ((org-special-ctrl-a/e nil))
633 (and (progn (org-end-of-line) (eolp))
634 (progn (org-end-of-line) (eolp))))))
635 ;; At an headline, with reversed movement.
636 (should
637 (org-test-with-temp-text "* Headline3 :tag:\n"
638 (let ((org-special-ctrl-a/e 'reversed)
639 (this-command last-command))
640 (and (progn (org-end-of-line) (eolp))
641 (progn (org-end-of-line) (looking-at " :tag:"))))))
642 ;; At a block without hidden contents.
643 (should
644 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
645 (progn (org-end-of-line) (eolp))))
646 ;; At a block with hidden contents.
647 (should-not
648 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
649 (let ((org-special-ctrl-a/e t))
650 (org-hide-block-toggle)
651 (org-end-of-line)
652 (eobp)))))
654 (ert-deftest test-org/forward-paragraph ()
655 "Test `org-forward-paragraph' specifications."
656 ;; At end of buffer, return an error.
657 (should-error
658 (org-test-with-temp-text "Paragraph"
659 (goto-char (point-max))
660 (org-forward-paragraph)))
661 ;; Standard test.
662 (should
663 (org-test-with-temp-text "P1\n\nP2\n\nP3"
664 (org-forward-paragraph)
665 (looking-at "P2")))
666 ;; Ignore depth.
667 (should
668 (org-test-with-temp-text "#+BEGIN_CENTER\nP1\n#+END_CENTER\nP2"
669 (org-forward-paragraph)
670 (looking-at "P1")))
671 ;; Do not enter elements with invisible contents.
672 (should
673 (org-test-with-temp-text "#+BEGIN_CENTER\nP1\n\nP2\n#+END_CENTER\nP3"
674 (org-hide-block-toggle)
675 (org-forward-paragraph)
676 (looking-at "P3")))
677 ;; On an affiliated keyword, jump to the beginning of the element.
678 (should
679 (org-test-with-temp-text "#+name: para\n#+caption: caption\nPara"
680 (org-forward-paragraph)
681 (looking-at "Para")))
682 ;; On an item or a footnote definition, move to the second element
683 ;; inside, if any.
684 (should
685 (org-test-with-temp-text "- Item1\n\n Paragraph\n- Item2"
686 (org-forward-paragraph)
687 (looking-at " Paragraph")))
688 (should
689 (org-test-with-temp-text "[fn:1] Def1\n\nParagraph\n\n[fn:2] Def2"
690 (org-forward-paragraph)
691 (looking-at "Paragraph")))
692 ;; On an item, or a footnote definition, when the first line is
693 ;; empty, move to the first item.
694 (should
695 (org-test-with-temp-text "- \n\n Paragraph\n- Item2"
696 (org-forward-paragraph)
697 (looking-at " Paragraph")))
698 (should
699 (org-test-with-temp-text "[fn:1]\n\nParagraph\n\n[fn:2] Def2"
700 (org-forward-paragraph)
701 (looking-at "Paragraph")))
702 ;; On a table (resp. a property drawer) do not move through table
703 ;; rows (resp. node properties).
704 (should
705 (org-test-with-temp-text "| a | b |\n| c | d |\nParagraph"
706 (org-forward-paragraph)
707 (looking-at "Paragraph")))
708 (should
709 (org-test-with-temp-text ":PROPERTIES:\n:prop: value\n:END:\nParagraph"
710 (org-forward-paragraph)
711 (looking-at "Paragraph")))
712 ;; On a verse or source block, stop after blank lines.
713 (should
714 (org-test-with-temp-text "#+BEGIN_VERSE\nL1\n\nL2\n#+END_VERSE"
715 (org-forward-paragraph)
716 (looking-at "L2")))
717 (should
718 (org-test-with-temp-text "#+BEGIN_SRC\nL1\n\nL2\n#+END_SRC"
719 (org-forward-paragraph)
720 (looking-at "L2"))))
722 (ert-deftest test-org/backward-paragraph ()
723 "Test `org-backward-paragraph' specifications."
724 ;; Error at beginning of buffer.
725 (should-error
726 (org-test-with-temp-text "Paragraph"
727 (org-backward-paragraph)))
728 ;; Regular test.
729 (should
730 (org-test-with-temp-text "P1\n\nP2\n\nP3"
731 (goto-char (point-max))
732 (org-backward-paragraph)
733 (looking-at "P3")))
734 (should
735 (org-test-with-temp-text "P1\n\nP2\n\nP3"
736 (goto-char (point-max))
737 (beginning-of-line)
738 (org-backward-paragraph)
739 (looking-at "P2")))
740 ;; Ignore depth.
741 (should
742 (org-test-with-temp-text "P1\n\n#+BEGIN_CENTER\nP2\n#+END_CENTER\nP3"
743 (goto-char (point-max))
744 (beginning-of-line)
745 (org-backward-paragraph)
746 (looking-at "P2")))
747 ;; Ignore invisible elements.
748 (should
749 (org-test-with-temp-text "* H1\n P1\n* H2"
750 (org-cycle)
751 (goto-char (point-max))
752 (beginning-of-line)
753 (org-backward-paragraph)
754 (bobp)))
755 ;; On an affiliated keyword, jump to the first one.
756 (should
757 (org-test-with-temp-text "P1\n#+name: n\n#+caption: c1\n#+caption: c2\nP2"
758 (search-forward "c2")
759 (org-backward-paragraph)
760 (looking-at "#\\+name")))
761 ;; On the second element in an item or a footnote definition, jump
762 ;; to item or the definition.
763 (should
764 (org-test-with-temp-text "- line1\n\n line2"
765 (goto-char (point-max))
766 (beginning-of-line)
767 (org-backward-paragraph)
768 (looking-at "- line1")))
769 (should
770 (org-test-with-temp-text "[fn:1] line1\n\n line2"
771 (goto-char (point-max))
772 (beginning-of-line)
773 (org-backward-paragraph)
774 (looking-at "\\[fn:1\\] line1")))
775 ;; On a table (resp. a property drawer), ignore table rows
776 ;; (resp. node properties).
777 (should
778 (org-test-with-temp-text "| a | b |\n| c | d |\nP1"
779 (goto-char (point-max))
780 (beginning-of-line)
781 (org-backward-paragraph)
782 (bobp)))
783 (should
784 (org-test-with-temp-text ":PROPERTIES:\n:prop: value\n:END:\nP1"
785 (goto-char (point-max))
786 (beginning-of-line)
787 (org-backward-paragraph)
788 (bobp)))
789 ;; On a source or verse block, stop before blank lines.
790 (should
791 (org-test-with-temp-text "#+BEGIN_VERSE\nL1\n\nL2\n\nL3\n#+END_VERSE"
792 (search-forward "L3")
793 (beginning-of-line)
794 (org-backward-paragraph)
795 (looking-at "L2")))
796 (should
797 (org-test-with-temp-text "#+BEGIN_SRC\nL1\n\nL2\n\nL3#+END_SRC"
798 (search-forward "L3")
799 (beginning-of-line)
800 (org-backward-paragraph)
801 (looking-at "L2"))))
803 (ert-deftest test-org/forward-element ()
804 "Test `org-forward-element' specifications."
805 ;; 1. At EOB: should error.
806 (org-test-with-temp-text "Some text\n"
807 (goto-char (point-max))
808 (should-error (org-forward-element)))
809 ;; 2. Standard move: expected to ignore blank lines.
810 (org-test-with-temp-text "First paragraph.\n\n\nSecond paragraph."
811 (org-forward-element)
812 (should (looking-at (regexp-quote "Second paragraph."))))
813 ;; 3. Headline tests.
814 (org-test-with-temp-text "
815 * Head 1
816 ** Head 1.1
817 *** Head 1.1.1
818 ** Head 1.2"
819 ;; 3.1. At an headline beginning: move to next headline at the
820 ;; same level.
821 (goto-line 3)
822 (org-forward-element)
823 (should (looking-at (regexp-quote "** Head 1.2")))
824 ;; 3.2. At an headline beginning: move to parent headline if no
825 ;; headline at the same level.
826 (goto-line 3)
827 (org-forward-element)
828 (should (looking-at (regexp-quote "** Head 1.2"))))
829 ;; 4. Greater element tests.
830 (org-test-with-temp-text
831 "#+BEGIN_CENTER\nInside.\n#+END_CENTER\n\nOutside."
832 ;; 4.1. At a greater element: expected to skip contents.
833 (org-forward-element)
834 (should (looking-at (regexp-quote "Outside.")))
835 ;; 4.2. At the end of greater element contents: expected to skip
836 ;; to the end of the greater element.
837 (goto-line 2)
838 (org-forward-element)
839 (should (looking-at (regexp-quote "Outside."))))
840 ;; 5. List tests.
841 (org-test-with-temp-text "
842 - item1
844 - sub1
846 - sub2
848 - sub3
850 Inner paragraph.
852 - item2
854 Outside."
855 ;; 5.1. At list top point: expected to move to the element after
856 ;; the list.
857 (goto-line 2)
858 (org-forward-element)
859 (should (looking-at (regexp-quote "Outside.")))
860 ;; 5.2. Special case: at the first line of a sub-list, but not at
861 ;; beginning of line, move to next item.
862 (goto-line 2)
863 (forward-char)
864 (org-forward-element)
865 (should (looking-at "- item2"))
866 (goto-line 4)
867 (forward-char)
868 (org-forward-element)
869 (should (looking-at " - sub2"))
870 ;; 5.3 At sub-list beginning: expected to move after the sub-list.
871 (goto-line 4)
872 (org-forward-element)
873 (should (looking-at (regexp-quote " Inner paragraph.")))
874 ;; 5.4. At sub-list end: expected to move outside the sub-list.
875 (goto-line 8)
876 (org-forward-element)
877 (should (looking-at (regexp-quote " Inner paragraph.")))
878 ;; 5.5. At an item: expected to move to next item, if any.
879 (goto-line 6)
880 (org-forward-element)
881 (should (looking-at " - sub3"))))
883 (ert-deftest test-org/backward-element ()
884 "Test `org-backward-element' specifications."
885 ;; 1. Should error at BOB.
886 (org-test-with-temp-text " \nParagraph."
887 (should-error (org-backward-element)))
888 ;; 2. Should move at BOB when called on the first element in buffer.
889 (should
890 (org-test-with-temp-text "\n#+TITLE: test"
891 (progn (forward-line)
892 (org-backward-element)
893 (bobp))))
894 ;; 3. Not at the beginning of an element: move at its beginning.
895 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
896 (goto-line 3)
897 (end-of-line)
898 (org-backward-element)
899 (should (looking-at (regexp-quote "Paragraph2."))))
900 ;; 4. Headline tests.
901 (org-test-with-temp-text "
902 * Head 1
903 ** Head 1.1
904 *** Head 1.1.1
905 ** Head 1.2"
906 ;; 4.1. At an headline beginning: move to previous headline at the
907 ;; same level.
908 (goto-line 5)
909 (org-backward-element)
910 (should (looking-at (regexp-quote "** Head 1.1")))
911 ;; 4.2. At an headline beginning: move to parent headline if no
912 ;; headline at the same level.
913 (goto-line 3)
914 (org-backward-element)
915 (should (looking-at (regexp-quote "* Head 1")))
916 ;; 4.3. At the first top-level headline: should error.
917 (goto-line 2)
918 (should-error (org-backward-element)))
919 ;; 5. At beginning of first element inside a greater element:
920 ;; expected to move to greater element's beginning.
921 (org-test-with-temp-text "Before.\n#+BEGIN_CENTER\nInside.\n#+END_CENTER"
922 (goto-line 3)
923 (org-backward-element)
924 (should (looking-at "#\\+BEGIN_CENTER")))
925 ;; 6. At the beginning of the first element in a section: should
926 ;; move back to headline, if any.
927 (should
928 (org-test-with-temp-text "#+TITLE: test\n* Headline\n\nParagraph"
929 (progn (goto-char (point-max))
930 (beginning-of-line)
931 (org-backward-element)
932 (org-at-heading-p))))
933 ;; 7. List tests.
934 (org-test-with-temp-text "
935 - item1
937 - sub1
939 - sub2
941 - sub3
943 Inner paragraph.
945 - item2
948 Outside."
949 ;; 7.1. At beginning of sub-list: expected to move to the
950 ;; paragraph before it.
951 (goto-line 4)
952 (org-backward-element)
953 (should (looking-at "item1"))
954 ;; 7.2. At an item in a list: expected to move at previous item.
955 (goto-line 8)
956 (org-backward-element)
957 (should (looking-at " - sub2"))
958 (goto-line 12)
959 (org-backward-element)
960 (should (looking-at "- item1"))
961 ;; 7.3. At end of list/sub-list: expected to move to list/sub-list
962 ;; beginning.
963 (goto-line 10)
964 (org-backward-element)
965 (should (looking-at " - sub1"))
966 (goto-line 15)
967 (org-backward-element)
968 (should (looking-at "- item1"))
969 ;; 7.4. At blank-lines before list end: expected to move to top
970 ;; item.
971 (goto-line 14)
972 (org-backward-element)
973 (should (looking-at "- item1"))))
975 (ert-deftest test-org/up-element ()
976 "Test `org-up-element' specifications."
977 ;; 1. At BOB or with no surrounding element: should error.
978 (org-test-with-temp-text "Paragraph."
979 (should-error (org-up-element)))
980 (org-test-with-temp-text "* Head1\n* Head2"
981 (goto-line 2)
982 (should-error (org-up-element)))
983 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
984 (goto-line 3)
985 (should-error (org-up-element)))
986 ;; 2. At an headline: move to parent headline.
987 (org-test-with-temp-text "* Head1\n** Sub-Head1\n** Sub-Head2"
988 (goto-line 3)
989 (org-up-element)
990 (should (looking-at "\\* Head1")))
991 ;; 3. Inside a greater element: move to greater element beginning.
992 (org-test-with-temp-text
993 "Before.\n#+BEGIN_CENTER\nParagraph1\nParagraph2\n#+END_CENTER\n"
994 (goto-line 3)
995 (org-up-element)
996 (should (looking-at "#\\+BEGIN_CENTER")))
997 ;; 4. List tests.
998 (org-test-with-temp-text "* Top
999 - item1
1001 - sub1
1003 - sub2
1005 Paragraph within sub2.
1007 - item2"
1008 ;; 4.1. Within an item: move to the item beginning.
1009 (goto-line 8)
1010 (org-up-element)
1011 (should (looking-at " - sub2"))
1012 ;; 4.2. At an item in a sub-list: move to parent item.
1013 (goto-line 4)
1014 (org-up-element)
1015 (should (looking-at "- item1"))
1016 ;; 4.3. At an item in top list: move to beginning of whole list.
1017 (goto-line 10)
1018 (org-up-element)
1019 (should (looking-at "- item1"))
1020 ;; 4.4. Special case. At very top point: should move to parent of
1021 ;; list.
1022 (goto-line 2)
1023 (org-up-element)
1024 (should (looking-at "\\* Top"))))
1026 (ert-deftest test-org/down-element ()
1027 "Test `org-down-element' specifications."
1028 ;; Error when the element hasn't got a recursive type.
1029 (org-test-with-temp-text "Paragraph."
1030 (should-error (org-down-element)))
1031 ;; Error when the element has no contents
1032 (org-test-with-temp-text "* Headline"
1033 (should-error (org-down-element)))
1034 ;; When at a plain-list, move to first item.
1035 (org-test-with-temp-text "- Item 1\n - Item 1.1\n - Item 2.2"
1036 (goto-line 2)
1037 (org-down-element)
1038 (should (looking-at " - Item 1.1")))
1039 (org-test-with-temp-text "#+NAME: list\n- Item 1"
1040 (org-down-element)
1041 (should (looking-at " Item 1")))
1042 ;; When at a table, move to first row
1043 (org-test-with-temp-text "#+NAME: table\n| a | b |"
1044 (org-down-element)
1045 (should (looking-at " a | b |")))
1046 ;; Otherwise, move inside the greater element.
1047 (org-test-with-temp-text "#+BEGIN_CENTER\nParagraph.\n#+END_CENTER"
1048 (org-down-element)
1049 (should (looking-at "Paragraph"))))
1051 (ert-deftest test-org/drag-element-backward ()
1052 "Test `org-drag-element-backward' specifications."
1053 ;; 1. Error when trying to move first element of buffer.
1054 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
1055 (should-error (org-drag-element-backward)))
1056 ;; 2. Error when trying to swap nested elements.
1057 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
1058 (forward-line)
1059 (should-error (org-drag-element-backward)))
1060 ;; 3. Error when trying to swap an headline element and
1061 ;; a non-headline element.
1062 (org-test-with-temp-text "Test.\n* Head 1"
1063 (forward-line)
1064 (should-error (org-drag-element-backward)))
1065 ;; 4. Otherwise, swap elements, preserving column and blank lines
1066 ;; between elements.
1067 (org-test-with-temp-text "Para1\n\n\nParagraph 2\n\nPara3"
1068 (search-forward "graph")
1069 (org-drag-element-backward)
1070 (should (equal (buffer-string) "Paragraph 2\n\n\nPara1\n\nPara3"))
1071 (should (looking-at " 2")))
1072 ;; 5. Preserve visibility of elements and their contents.
1073 (org-test-with-temp-text "
1074 #+BEGIN_CENTER
1075 Text.
1076 #+END_CENTER
1077 - item 1
1078 #+BEGIN_QUOTE
1079 Text.
1080 #+END_QUOTE"
1081 (while (search-forward "BEGIN_" nil t) (org-cycle))
1082 (search-backward "- item 1")
1083 (org-drag-element-backward)
1084 (should
1085 (equal
1086 '((63 . 82) (26 . 48))
1087 (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
1088 (overlays-in (point-min) (point-max)))))))
1090 (ert-deftest test-org/drag-element-forward ()
1091 "Test `org-drag-element-forward' specifications."
1092 ;; 1. Error when trying to move first element of buffer.
1093 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
1094 (goto-line 3)
1095 (should-error (org-drag-element-forward)))
1096 ;; 2. Error when trying to swap nested elements.
1097 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
1098 (forward-line)
1099 (should-error (org-drag-element-forward)))
1100 ;; 3. Error when trying to swap a non-headline element and an
1101 ;; headline.
1102 (org-test-with-temp-text "Test.\n* Head 1"
1103 (should-error (org-drag-element-forward)))
1104 ;; 4. Otherwise, swap elements, preserving column and blank lines
1105 ;; between elements.
1106 (org-test-with-temp-text "Paragraph 1\n\n\nPara2\n\nPara3"
1107 (search-forward "graph")
1108 (org-drag-element-forward)
1109 (should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
1110 (should (looking-at " 1")))
1111 ;; 5. Preserve visibility of elements and their contents.
1112 (org-test-with-temp-text "
1113 #+BEGIN_CENTER
1114 Text.
1115 #+END_CENTER
1116 - item 1
1117 #+BEGIN_QUOTE
1118 Text.
1119 #+END_QUOTE"
1120 (while (search-forward "BEGIN_" nil t) (org-cycle))
1121 (search-backward "#+BEGIN_CENTER")
1122 (org-drag-element-forward)
1123 (should
1124 (equal
1125 '((63 . 82) (26 . 48))
1126 (mapcar (lambda (ov) (cons (overlay-start ov) (overlay-end ov)))
1127 (overlays-in (point-min) (point-max)))))))
1131 ;;; Planning
1133 (ert-deftest test-org/timestamp-has-time-p ()
1134 "Test `org-timestamp-has-time-p' specifications."
1135 ;; With time.
1136 (should
1137 (org-test-with-temp-text "<2012-03-29 Thu 16:40>"
1138 (org-timestamp-has-time-p (org-element-context))))
1139 ;; Without time.
1140 (should-not
1141 (org-test-with-temp-text "<2012-03-29 Thu>"
1142 (org-timestamp-has-time-p (org-element-context)))))
1144 (ert-deftest test-org/timestamp-format ()
1145 "Test `org-timestamp-format' specifications."
1146 ;; Regular test.
1147 (should
1148 (equal
1149 "2012-03-29 16:40"
1150 (org-test-with-temp-text "<2012-03-29 Thu 16:40>"
1151 (org-timestamp-format (org-element-context) "%Y-%m-%d %R"))))
1152 ;; Range end.
1153 (should
1154 (equal
1155 "2012-03-29"
1156 (org-test-with-temp-text "[2011-07-14 Thu]--[2012-03-29 Thu]"
1157 (org-timestamp-format (org-element-context) "%Y-%m-%d" t)))))
1159 (ert-deftest test-org/timestamp-split-range ()
1160 "Test `org-timestamp-split-range' specifications."
1161 ;; Extract range start (active).
1162 (should
1163 (equal '(2012 3 29)
1164 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1165 (let ((ts (org-timestamp-split-range (org-element-context))))
1166 (mapcar (lambda (p) (org-element-property p ts))
1167 '(:year-end :month-end :day-end))))))
1168 ;; Extract range start (inactive)
1169 (should
1170 (equal '(2012 3 29)
1171 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
1172 (let ((ts (org-timestamp-split-range (org-element-context))))
1173 (mapcar (lambda (p) (org-element-property p ts))
1174 '(:year-end :month-end :day-end))))))
1175 ;; Extract range end (active).
1176 (should
1177 (equal '(2012 3 30)
1178 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1179 (let ((ts (org-timestamp-split-range
1180 (org-element-context) t)))
1181 (mapcar (lambda (p) (org-element-property p ts))
1182 '(:year-end :month-end :day-end))))))
1183 ;; Extract range end (inactive)
1184 (should
1185 (equal '(2012 3 30)
1186 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
1187 (let ((ts (org-timestamp-split-range
1188 (org-element-context) t)))
1189 (mapcar (lambda (p) (org-element-property p ts))
1190 '(:year-end :month-end :day-end))))))
1191 ;; Return the timestamp if not a range.
1192 (should
1193 (org-test-with-temp-text "[2012-03-29 Thu]"
1194 (let* ((ts-orig (org-element-context))
1195 (ts-copy (org-timestamp-split-range ts-orig)))
1196 (eq ts-orig ts-copy))))
1197 (should
1198 (org-test-with-temp-text "<%%(org-float t 4 2)>"
1199 (let* ((ts-orig (org-element-context))
1200 (ts-copy (org-timestamp-split-range ts-orig)))
1201 (eq ts-orig ts-copy))))
1202 ;; Check that parent is the same when a range was split.
1203 (should
1204 (org-test-with-temp-text "[2012-03-29 Thu]--[2012-03-30 Fri]"
1205 (let* ((ts-orig (org-element-context))
1206 (ts-copy (org-timestamp-split-range ts-orig)))
1207 (eq (org-element-property :parent ts-orig)
1208 (org-element-property :parent ts-copy))))))
1210 (ert-deftest test-org/timestamp-translate ()
1211 "Test `org-timestamp-translate' specifications."
1212 ;; Translate whole date range.
1213 (should
1214 (equal "<29>--<30>"
1215 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1216 (let ((org-display-custom-times t)
1217 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1218 (org-timestamp-translate (org-element-context))))))
1219 ;; Translate date range start.
1220 (should
1221 (equal "<29>"
1222 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1223 (let ((org-display-custom-times t)
1224 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1225 (org-timestamp-translate (org-element-context) 'start)))))
1226 ;; Translate date range end.
1227 (should
1228 (equal "<30>"
1229 (org-test-with-temp-text "<2012-03-29 Thu>--<2012-03-30 Fri>"
1230 (let ((org-display-custom-times t)
1231 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1232 (org-timestamp-translate (org-element-context) 'end)))))
1233 ;; Translate time range.
1234 (should
1235 (equal "<08>--<16>"
1236 (org-test-with-temp-text "<2012-03-29 Thu 8:30-16:40>"
1237 (let ((org-display-custom-times t)
1238 (org-time-stamp-custom-formats '("<%d>" . "<%H>")))
1239 (org-timestamp-translate (org-element-context))))))
1240 ;; Translate non-range timestamp.
1241 (should
1242 (equal "<29>"
1243 (org-test-with-temp-text "<2012-03-29 Thu>"
1244 (let ((org-display-custom-times t)
1245 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1246 (org-timestamp-translate (org-element-context))))))
1247 ;; Do not change `diary' timestamps.
1248 (should
1249 (equal "<%%(org-float t 4 2)>"
1250 (org-test-with-temp-text "<%%(org-float t 4 2)>"
1251 (let ((org-display-custom-times t)
1252 (org-time-stamp-custom-formats '("<%d>" . "<%d>")))
1253 (org-timestamp-translate (org-element-context)))))))
1257 ;;; Targets and Radio Targets
1259 (ert-deftest test-org/all-targets ()
1260 "Test `org-all-targets' specifications."
1261 ;; Without an argument.
1262 (should
1263 (equal '("radio-target" "target")
1264 (org-test-with-temp-text "<<target>> <<<radio-target>>>\n: <<verb>>"
1265 (org-all-targets))))
1266 (should
1267 (equal '("radio-target")
1268 (org-test-with-temp-text "<<<radio-target>>>!" (org-all-targets))))
1269 ;; With argument.
1270 (should
1271 (equal '("radio-target")
1272 (org-test-with-temp-text "<<target>> <<<radio-target>>>"
1273 (org-all-targets t)))))
1276 (provide 'test-org)
1278 ;;; test-org.el ends here