Update copyright years.
[org-mode.git] / testing / lisp / test-org-src.el
blobde212a297b2c6a54d12cae49b9531504c16869df
1 ;;; test-org-src.el --- tests for org-src.el
3 ;; Copyright (C) 2012, 2013, 2014 Le Wang
5 ;; Author: Le Wang <l26wang at gmail dot com>
7 ;; This file is not part of GNU Emacs.
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Code:
24 (require 'org-test)
28 (ert-deftest test-org-src/basic ()
29 "Editing regular block works. with point on
31 #+begin_src line
33 (org-test-with-temp-text
35 #+begin_src emacs-lisp
36 (message hello)
37 #+end_src
39 (goto-line 2)
40 (org-edit-special)
41 (insert "blah")
42 (org-edit-src-exit)
43 (should (equal (buffer-string) "
44 #+begin_src emacs-lisp
45 blah(message hello)
46 #+end_src
47 "))
48 (should (equal (word-at-point) "blah"))))
50 (ert-deftest test-org-src/point-outside-block ()
51 "Editing with point before/after block signals expected error."
52 (org-test-with-temp-text
54 #+begin_src emacs-lisp
55 (message hello)
56 #+end_src
58 (goto-line 1)
59 (should-error (org-edit-special))
60 (goto-char (point-max))
61 (should-error (org-edit-special))))
63 (ert-deftest test-org-src/empty-block ()
64 "Editing empty block."
65 (org-test-with-temp-text
67 #+begin_src emacs-lisp
68 #+end_src
70 (goto-line 2)
71 (org-edit-special)
72 (insert "blah")
73 (org-edit-src-exit)
74 (should (equal (buffer-string) "
75 #+begin_src emacs-lisp
76 blah
77 #+end_src
78 "))
79 (should (equal (word-at-point) "blah"))))
81 (ert-deftest test-org-src/blank-line-block ()
82 "Editing block with just a blank line."
83 (org-test-with-temp-text-in-file
85 #+begin_src emacs-lisp
87 #+end_src
89 (goto-line 2)
90 (org-edit-special)
91 (insert "blah")
92 (org-edit-src-exit)
93 (should (equal (buffer-string) "
94 #+begin_src emacs-lisp
95 blah
96 #+end_src
97 "))))
99 (provide 'test-org-src)
100 ;;; test-org-src.el ends here