3 ;; Copyright (c) ߚ David Maus
6 ;; Released under the GNU General Public License version 3
7 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
11 ;; Template test file for Org-mode tests
18 (ert-deftest test-org
/comment-dwim
()
19 "Test `comment-dwim' behaviour in an Org buffer."
20 ;; No region selected, no comment on current line and line not
21 ;; empty: insert comment on line above.
24 (org-test-with-temp-text "Comment"
25 (progn (call-interactively 'comment-dwim
)
27 ;; No region selected, no comment on current line and line empty:
28 ;; insert comment on this line.
30 (equal "# \nParagraph"
31 (org-test-with-temp-text "\nParagraph"
32 (progn (call-interactively 'comment-dwim
)
34 ;; No region selected, and a comment on this line: indent it.
36 (equal "* Headline\n # Comment"
37 (org-test-with-temp-text "* Headline\n# Comment"
39 (let ((org-adapt-indentation t
))
40 (call-interactively 'comment-dwim
))
42 ;; Also recognize single # at column 0 as comments.
45 (org-test-with-temp-text "# Comment"
47 (call-interactively 'comment-dwim
)
49 ;; Region selected and only comments and blank lines within it:
50 ;; un-comment all commented lines.
52 (equal "Comment 1\n\nComment 2"
53 (org-test-with-temp-text "# Comment 1\n\n# Comment 2"
55 (transient-mark-mode 1)
56 (push-mark (point) t t
)
57 (goto-char (point-max))
58 (call-interactively 'comment-dwim
)
60 ;; Region selected without comments: comment all non-blank lines.
62 (equal "# Comment 1\n\n# Comment 2"
63 (org-test-with-temp-text "Comment 1\n\nComment 2"
65 (transient-mark-mode 1)
66 (push-mark (point) t t
)
67 (goto-char (point-max))
68 (call-interactively 'comment-dwim
)
70 ;; In front of a keyword without region, insert a new comment.
72 (equal "# \n#+KEYWORD: value"
73 (org-test-with-temp-text "#+KEYWORD: value"
74 (progn (call-interactively 'comment-dwim
)
81 (ert-deftest test-org
/org-read-date
()
82 "Test `org-read-date' specifications."
83 ;; Parse ISO date with abbreviated year and month.
84 (should (equal "2012-03-29 16:40"
85 (let ((org-time-was-given t
))
86 (org-read-date t nil
"12-3-29 16:40"))))
87 ;; Parse Europeans dates.
88 (should (equal "2012-03-29 16:40"
89 (let ((org-time-was-given t
))
90 (org-read-date t nil
"29.03.2012 16:40"))))
91 ;; Parse Europeans dates without year.
92 (should (string-match "2[0-9]\\{3\\}-03-29 16:40"
93 (let ((org-time-was-given t
))
94 (org-read-date t nil
"29.03. 16:40")))))
100 (ert-deftest test-org
/fill-paragraph
()
101 "Test `org-fill-paragraph' specifications."
102 ;; At an Org table, align it.
103 (org-test-with-temp-text "|a|"
105 (should (equal (buffer-string) "| a |\n")))
106 ;; At a paragraph, preserve line breaks.
107 (org-test-with-temp-text "some \\\\\nlong\ntext"
108 (let ((fill-column 20))
110 (should (equal (buffer-string) "some \\\\\nlong text"))))
111 ;; Correctly fill a paragraph when point is at its very end.
114 (org-test-with-temp-text "A\nB"
115 (let ((fill-column 20))
116 (goto-char (point-max))
119 ;; Correctly fill the last paragraph of a greater element.
121 (equal "#+BEGIN_CENTER\n- 012345\n 789\n#+END_CENTER"
122 (org-test-with-temp-text "#+BEGIN_CENTER\n- 012345 789\n#+END_CENTER"
123 (let ((fill-column 8))
128 ;; Correctly fill an element in a narrowed buffer.
131 (org-test-with-temp-text "01234 6789"
132 (let ((fill-column 5))
133 (narrow-to-region 1 8)
136 ;; Special case: Fill first paragraph when point is at an item or
137 ;; a plain-list or a footnote reference.
140 (org-test-with-temp-text "- A\n B"
141 (let ((fill-column 20))
146 (org-test-with-temp-text "[fn:1] A\nB"
147 (let ((fill-column 20))
150 (org-test-with-temp-text "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"
151 (let ((fill-column 20))
153 (should (equal (buffer-string)
154 "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE"))))
155 ;; Fill contents of `comment-block' elements.
158 (org-test-with-temp-text "#+BEGIN_COMMENT\nSome\ntext\n#+END_COMMENT"
159 (let ((fill-column 20))
163 "#+BEGIN_COMMENT\nSome text\n#+END_COMMENT"))
164 ;; Fill `comment' elements.
167 (org-test-with-temp-text " # A\n # B"
168 (let ((fill-column 20))
171 ;; Do nothing at affiliated keywords.
172 (org-test-with-temp-text "#+NAME: para\nSome\ntext."
173 (let ((fill-column 20))
175 (should (equal (buffer-string) "#+NAME: para\nSome\ntext.")))))
177 (ert-deftest test-org
/auto-fill-function
()
178 "Test auto-filling features."
179 ;; Auto fill paragraph.
182 (org-test-with-temp-text "12345 7890"
183 (let ((fill-column 5))
185 (org-auto-fill-function)
187 ;; Auto fill first paragraph in an item.
189 (equal "- 12345\n 7890"
190 (org-test-with-temp-text "- 12345 7890"
191 (let ((fill-column 7))
193 (org-auto-fill-function)
195 ;; Auto fill comments.
197 (equal " # 12345\n # 7890"
198 (org-test-with-temp-text " # 12345 7890"
199 (let ((fill-column 10))
201 (org-auto-fill-function)
203 ;; A hash within a line isn't a comment.
205 (equal "12345 # 7890\n# 1"
206 (org-test-with-temp-text "12345 # 7890 1"
207 (let ((fill-column 12))
209 (org-auto-fill-function)
211 ;; Correctly interpret empty prefix.
213 (equal "# a\n# b\nRegular\n# paragraph"
214 (org-test-with-temp-text "# a\n# b\nRegular paragraph"
215 (let ((fill-column 12))
217 (org-auto-fill-function)
219 ;; Comment block: auto fill contents.
221 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
222 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
223 (let ((fill-column 5))
226 (org-auto-fill-function)
229 (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"
230 (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT"
231 (let ((fill-column 5))
234 (org-auto-fill-function)
236 ;; Do not fill if a new item could be created.
239 (org-test-with-temp-text "12345 - 90"
240 (let ((fill-column 5))
242 (org-auto-fill-function)
244 ;; Do not fill if a line break could be introduced.
246 (equal "123\\\\\n7890"
247 (org-test-with-temp-text "123\\\\ 7890"
248 (let ((fill-column 6))
250 (org-auto-fill-function)
252 ;; Do not fill affiliated keywords.
254 (equal "#+ATTR_LATEX: ABC\nDEFGHIJKL"
255 (org-test-with-temp-text "#+ATTR_LATEX: ABC DEFGHIJKL"
256 (let ((fill-column 20))
258 (org-auto-fill-function)
267 ;; Fuzzy links [[text]] encompass links to a target (<<text>>), to
268 ;; a target keyword (aka an invisible target: #+TARGET: text), to
269 ;; a named element (#+name: text) and to headlines (* Text).
271 (ert-deftest test-org
/fuzzy-links
()
272 "Test fuzzy links specifications."
273 ;; 1. Fuzzy link goes in priority to a matching target.
274 (org-test-with-temp-text
275 "#+TARGET: Test\n#+NAME: Test\n|a|b|\n<<Test>>\n* Test\n[[Test]]"
278 (should (looking-at "<<Test>>")))
279 ;; 2. Fuzzy link should then go to a matching target keyword.
280 (org-test-with-temp-text
281 "#+NAME: Test\n|a|b|\n#+TARGET: Test\n* Test\n[[Test]]"
284 (should (looking-at "#\\+TARGET: Test")))
285 ;; 3. Then fuzzy link points to an element with a given name.
286 (org-test-with-temp-text "Test\n#+NAME: Test\n|a|b|\n* Test\n[[Test]]"
289 (should (looking-at "#\\+NAME: Test")))
290 ;; 4. A target still lead to a matching headline otherwise.
291 (org-test-with-temp-text "* Head1\n* Head2\n*Head3\n[[Head2]]"
294 (should (looking-at "\\* Head2")))
295 ;; 5. With a leading star in link, enforce heading match.
296 (org-test-with-temp-text "#+TARGET: Test\n* Test\n<<Test>>\n[[*Test]]"
299 (should (looking-at "\\* Test"))))
304 (ert-deftest test-org
/org-link-escape-ascii-character
()
305 "Escape an ascii character."
309 (org-link-escape "["))))
311 (ert-deftest test-org
/org-link-escape-ascii-ctrl-character
()
312 "Escape an ascii control character."
316 (org-link-escape "\t"))))
318 (ert-deftest test-org
/org-link-escape-multibyte-character
()
319 "Escape an unicode multibyte character."
323 (org-link-escape "€"))))
325 (ert-deftest test-org
/org-link-escape-custom-table
()
326 "Escape string with custom character table."
330 (org-link-escape "Foo:Bar\n" '(?\
: ?\B
)))))
332 (ert-deftest test-org
/org-link-escape-custom-table-merge
()
333 "Escape string with custom table merged with default table."
336 "%5BF%6F%6F%3A%42ar%0A%5D"
337 (org-link-escape "[Foo:Bar\n]" '(?\
: ?\B ?\o
) t
))))
339 (ert-deftest test-org
/org-link-unescape-ascii-character
()
340 "Unescape an ascii character."
344 (org-link-unescape "%5B"))))
346 (ert-deftest test-org
/org-link-unescape-ascii-ctrl-character
()
347 "Unescpae an ascii control character."
351 (org-link-unescape "%0A"))))
353 (ert-deftest test-org
/org-link-unescape-multibyte-character
()
354 "Unescape unicode multibyte character."
358 (org-link-unescape "%E2%82%AC"))))
360 (ert-deftest test-org
/org-link-unescape-ascii-extended-char
()
361 "Unescape old style percent escaped character."
365 (decode-coding-string (org-link-unescape "%E0%E2%E7%E8%E9%EA%EE%F4%F9%FB") 'latin-1
))))
367 (ert-deftest test-org
/org-link-escape-url-with-escaped-char
()
368 "Escape and unscape a URL that includes an escaped char.
369 http://article.gmane.org/gmane.emacs.orgmode/21459/"
372 "http://some.host.com/form?&id=blah%2Bblah25"
373 (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25")))))
379 (ert-deftest test-org
/macro-replace-all
()
380 "Test `org-macro-replace-all' specifications."
384 "#+MACRO: A B\n1 B 3"
385 (org-test-with-temp-text "#+MACRO: A B\n1 {{{A}}} 3"
386 (progn (org-macro-initialize-templates)
387 (org-macro-replace-all org-macro-templates
)
389 ;; Macro with arguments.
392 "#+MACRO: macro $1 $2\nsome text"
393 (org-test-with-temp-text "#+MACRO: macro $1 $2\n{{{macro(some,text)}}}"
394 (progn (org-macro-initialize-templates)
395 (org-macro-replace-all org-macro-templates
)
397 ;; Macro with "eval".
400 "#+MACRO: add (eval (+ $1 $2))\n3"
401 (org-test-with-temp-text "#+MACRO: add (eval (+ $1 $2))\n{{{add(1,2)}}}"
402 (progn (org-macro-initialize-templates)
403 (org-macro-replace-all org-macro-templates
)
408 "#+MACRO: in inner\n#+MACRO: out {{{in}}} outer\ninner outer"
409 (org-test-with-temp-text
410 "#+MACRO: in inner\n#+MACRO: out {{{in}}} outer\n{{{out}}}"
411 (progn (org-macro-initialize-templates)
412 (org-macro-replace-all org-macro-templates
)
414 ;; Error out when macro expansion is circular.
416 (org-test-with-temp-text
417 "#+MACRO: mac1 {{{mac2}}}\n#+MACRO: mac2 {{{mac1}}}\n{{{mac1}}}"
418 (org-macro-initialize-templates)
419 (org-macro-replace-all org-macro-templates
))))
425 (ert-deftest test-org
/accumulated-properties-in-drawers
()
426 "Ensure properties accumulate in subtree drawers."
427 (org-test-at-id "75282ba2-f77a-4309-a970-e87c149fe125"
428 (org-babel-next-src-block)
429 (should (equal '(2 1) (org-babel-execute-src-block)))))
435 (ert-deftest test-org
/mark-subtree
()
436 "Test `org-mark-subtree' specifications."
437 ;; Error when point is before first headline.
439 (org-test-with-temp-text "Paragraph\n* Headline\nBody"
440 (progn (transient-mark-mode 1)
441 (org-mark-subtree))))
442 ;; Without argument, mark current subtree.
446 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
447 (progn (transient-mark-mode 1)
450 (list (region-beginning) (region-end))))))
451 ;; With an argument, move ARG up.
455 (org-test-with-temp-text "* Headline\n** Sub-headline\nBody"
456 (progn (transient-mark-mode 1)
459 (list (region-beginning) (region-end))))))
460 ;; Do not get fooled by inlinetasks.
461 (when (featurep 'org-inlinetask
)
464 (org-test-with-temp-text "* Headline\n*************** Task\nContents"
465 (progn (transient-mark-mode 1)
467 (let ((org-inlinetask-min-level 15)) (org-mark-subtree))
468 (region-beginning)))))))
474 (ert-deftest test-org
/end-of-line
()
475 "Test `org-end-of-line' specifications."
478 (org-test-with-temp-text "Some text\nSome other text"
479 (progn (org-end-of-line) (eolp))))
480 ;; At an headline with special movement.
482 (org-test-with-temp-text "* Headline :tag:"
483 (let ((org-special-ctrl-a/e t
))
484 (and (progn (org-end-of-line) (looking-at " :tag:"))
485 (progn (org-end-of-line) (eolp))
486 (progn (org-end-of-line) (looking-at " :tag:"))))))
487 ;; At an headline without special movement.
489 (org-test-with-temp-text "* Headline :tag:"
490 (let ((org-special-ctrl-a/e nil
))
491 (and (progn (org-end-of-line) (eolp))
492 (progn (org-end-of-line) (eolp))))))
493 ;; At an headline, with reversed movement.
495 (org-test-with-temp-text "* Headline :tag:"
496 (let ((org-special-ctrl-a/e
'reversed
)
497 (this-command last-command
))
498 (and (progn (org-end-of-line) (eolp))
499 (progn (org-end-of-line) (looking-at " :tag:"))))))
500 ;; At a block without hidden contents.
502 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
503 (progn (org-end-of-line) (eolp))))
504 ;; At a block with hidden contents.
506 (org-test-with-temp-text "#+BEGIN_CENTER\nContents\n#+END_CENTER"
507 (progn (org-hide-block-toggle)
511 (ert-deftest test-org
/forward-element
()
512 "Test `org-forward-element' specifications."
513 ;; 1. At EOB: should error.
514 (org-test-with-temp-text "Some text\n"
515 (goto-char (point-max))
516 (should-error (org-forward-element)))
517 ;; 2. Standard move: expected to ignore blank lines.
518 (org-test-with-temp-text "First paragraph.\n\n\nSecond paragraph."
519 (org-forward-element)
520 (should (looking-at "Second paragraph.")))
521 ;; 3. Headline tests.
522 (org-test-with-temp-text "
527 ;; 3.1. At an headline beginning: move to next headline at the
530 (org-forward-element)
531 (should (looking-at "** Head 1.2"))
532 ;; 3.2. At an headline beginning: move to parent headline if no
533 ;; headline at the same level.
535 (org-forward-element)
536 (should (looking-at "** Head 1.2")))
537 ;; 4. Greater element tests.
538 (org-test-with-temp-text
539 "#+BEGIN_CENTER\nInside.\n#+END_CENTER\n\nOutside."
540 ;; 4.1. At a greater element: expected to skip contents.
541 (org-forward-element)
542 (should (looking-at "Outside."))
543 ;; 4.2. At the end of greater element contents: expected to skip
544 ;; to the end of the greater element.
546 (org-forward-element)
547 (should (looking-at "Outside.")))
549 (org-test-with-temp-text "
563 ;; 5.1. At list top point: expected to move to the element after
566 (org-forward-element)
567 (should (looking-at "Outside."))
568 ;; 5.2. Special case: at the first line of a sub-list, but not at
569 ;; beginning of line, move to next item.
572 (org-forward-element)
573 (should (looking-at "- item2"))
576 (org-forward-element)
577 (should (looking-at " - sub2"))
578 ;; 5.3 At sub-list beginning: expected to move after the sub-list.
580 (org-forward-element)
581 (should (looking-at " Inner paragraph."))
582 ;; 5.4. At sub-list end: expected to move outside the sub-list.
584 (org-forward-element)
585 (should (looking-at " Inner paragraph."))
586 ;; 5.5. At an item: expected to move to next item, if any.
588 (org-forward-element)
589 (should (looking-at " - sub3"))))
591 (ert-deftest test-org
/backward-element
()
592 "Test `org-backward-element' specifications."
593 ;; 1. Should error at BOB.
594 (org-test-with-temp-text " \nParagraph."
595 (should-error (org-backward-element)))
596 ;; 2. Should move at BOB when called on the first element in buffer.
598 (org-test-with-temp-text "\n#+TITLE: test"
599 (progn (forward-line)
600 (org-backward-element)
602 ;; 3. Not at the beginning of an element: move at its beginning.
603 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
606 (org-backward-element)
607 (should (looking-at "Paragraph2.")))
608 ;; 4. Headline tests.
609 (org-test-with-temp-text "
614 ;; 4.1. At an headline beginning: move to previous headline at the
617 (org-backward-element)
618 (should (looking-at "** Head 1.1"))
619 ;; 4.2. At an headline beginning: move to parent headline if no
620 ;; headline at the same level.
622 (org-backward-element)
623 (should (looking-at "* Head 1"))
624 ;; 4.3. At the first top-level headline: should error.
626 (should-error (org-backward-element)))
627 ;; 5. At beginning of first element inside a greater element:
628 ;; expected to move to greater element's beginning.
629 (org-test-with-temp-text "Before.\n#+BEGIN_CENTER\nInside.\n#+END_CENTER"
631 (org-backward-element)
632 (should (looking-at "#\\+BEGIN_CENTER")))
633 ;; 6. At the beginning of the first element in a section: should
634 ;; move back to headline, if any.
636 (org-test-with-temp-text "#+TITLE: test\n* Headline\n\nParagraph"
637 (progn (goto-char (point-max))
639 (org-backward-element)
640 (org-at-heading-p))))
642 (org-test-with-temp-text "
657 ;; 7.1. At beginning of sub-list: expected to move to the
658 ;; paragraph before it.
660 (org-backward-element)
661 (should (looking-at "item1"))
662 ;; 7.2. At an item in a list: expected to move at previous item.
664 (org-backward-element)
665 (should (looking-at " - sub2"))
667 (org-backward-element)
668 (should (looking-at "- item1"))
669 ;; 7.3. At end of list/sub-list: expected to move to list/sub-list
672 (org-backward-element)
673 (should (looking-at " - sub1"))
675 (org-backward-element)
676 (should (looking-at "- item1"))
677 ;; 7.4. At blank-lines before list end: expected to move to top
680 (org-backward-element)
681 (should (looking-at "- item1"))))
683 (ert-deftest test-org
/up-element
()
684 "Test `org-up-element' specifications."
685 ;; 1. At BOB or with no surrounding element: should error.
686 (org-test-with-temp-text "Paragraph."
687 (should-error (org-up-element)))
688 (org-test-with-temp-text "* Head1\n* Head2"
690 (should-error (org-up-element)))
691 (org-test-with-temp-text "Paragraph1.\n\nParagraph2."
693 (should-error (org-up-element)))
694 ;; 2. At an headline: move to parent headline.
695 (org-test-with-temp-text "* Head1\n** Sub-Head1\n** Sub-Head2"
698 (should (looking-at "\\* Head1")))
699 ;; 3. Inside a greater element: move to greater element beginning.
700 (org-test-with-temp-text
701 "Before.\n#+BEGIN_CENTER\nParagraph1\nParagraph2\n#+END_CENTER\n"
704 (should (looking-at "#\\+BEGIN_CENTER")))
706 (org-test-with-temp-text "* Top
713 Paragraph within sub2.
716 ;; 4.1. Within an item: move to the item beginning.
719 (should (looking-at " - sub2"))
720 ;; 4.2. At an item in a sub-list: move to parent item.
723 (should (looking-at "- item1"))
724 ;; 4.3. At an item in top list: move to beginning of whole list.
727 (should (looking-at "- item1"))
728 ;; 4.4. Special case. At very top point: should move to parent of
732 (should (looking-at "\\* Top"))))
734 (ert-deftest test-org
/down-element
()
735 "Test `org-down-element' specifications."
736 ;; Error when the element hasn't got a recursive type.
737 (org-test-with-temp-text "Paragraph."
738 (should-error (org-down-element)))
739 ;; Error when the element has no contents
740 (org-test-with-temp-text "* Headline"
741 (should-error (org-down-element)))
742 ;; When at a plain-list, move to first item.
743 (org-test-with-temp-text "- Item 1\n - Item 1.1\n - Item 2.2"
746 (should (looking-at " - Item 1.1")))
747 (org-test-with-temp-text "#+NAME: list\n- Item 1"
749 (should (looking-at " Item 1")))
750 ;; When at a table, move to first row
751 (org-test-with-temp-text "#+NAME: table\n| a | b |"
753 (should (looking-at " a | b |")))
754 ;; Otherwise, move inside the greater element.
755 (org-test-with-temp-text "#+BEGIN_CENTER\nParagraph.\n#+END_CENTER"
757 (should (looking-at "Paragraph"))))
759 (ert-deftest test-org
/drag-element-backward
()
760 "Test `org-drag-element-backward' specifications."
761 ;; 1. Error when trying to move first element of buffer.
762 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
763 (should-error (org-drag-element-backward)))
764 ;; 2. Error when trying to swap nested elements.
765 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
767 (should-error (org-drag-element-backward)))
768 ;; 3. Error when trying to swap an headline element and
769 ;; a non-headline element.
770 (org-test-with-temp-text "Test.\n* Head 1"
772 (should-error (org-drag-element-backward)))
773 ;; 4. Otherwise, swap elements, preserving column and blank lines
775 (org-test-with-temp-text "Para1\n\n\nParagraph 2\n\nPara3"
776 (search-forward "graph")
777 (org-drag-element-backward)
778 (should (equal (buffer-string) "Paragraph 2\n\n\nPara1\n\nPara3"))
779 (should (looking-at " 2")))
780 ;; 5. Preserve visibility of elements and their contents.
781 (org-test-with-temp-text "
789 (while (search-forward "BEGIN_" nil t
) (org-cycle))
790 (search-backward "- item 1")
791 (org-drag-element-backward)
794 '((63 .
82) (26 .
48))
795 (mapcar (lambda (ov) (cons (overlay-start ov
) (overlay-end ov
)))
796 (overlays-in (point-min) (point-max)))))))
798 (ert-deftest test-org
/drag-element-forward
()
799 "Test `org-drag-element-forward' specifications."
800 ;; 1. Error when trying to move first element of buffer.
801 (org-test-with-temp-text "Paragraph 1.\n\nParagraph 2."
803 (should-error (org-drag-element-forward)))
804 ;; 2. Error when trying to swap nested elements.
805 (org-test-with-temp-text "#+BEGIN_CENTER\nTest.\n#+END_CENTER"
807 (should-error (org-drag-element-forward)))
808 ;; 3. Error when trying to swap a non-headline element and an
810 (org-test-with-temp-text "Test.\n* Head 1"
811 (should-error (org-drag-element-forward)))
812 ;; 4. Otherwise, swap elements, preserving column and blank lines
814 (org-test-with-temp-text "Paragraph 1\n\n\nPara2\n\nPara3"
815 (search-forward "graph")
816 (org-drag-element-forward)
817 (should (equal (buffer-string) "Para2\n\n\nParagraph 1\n\nPara3"))
818 (should (looking-at " 1")))
819 ;; 5. Preserve visibility of elements and their contents.
820 (org-test-with-temp-text "
828 (while (search-forward "BEGIN_" nil t
) (org-cycle))
829 (search-backward "#+BEGIN_CENTER")
830 (org-drag-element-forward)
833 '((63 .
82) (26 .
48))
834 (mapcar (lambda (ov) (cons (overlay-start ov
) (overlay-end ov
)))
835 (overlays-in (point-min) (point-max)))))))
839 ;;; Targets and Radio Targets
841 (ert-deftest test-org
/all-targets
()
842 "Test `org-all-targets' specifications."
843 ;; Without an argument.
845 (equal '("radio-target" "target")
846 (org-test-with-temp-text "<<target>> <<<radio-target>>>\n: <<verb>>"
850 (equal '("radio-target")
851 (org-test-with-temp-text "<<target>> <<<radio-target>>>"
852 (org-all-targets t
)))))
857 ;;; test-org.el ends here