8b591144fe306007c8c2a05c8461af949cb5e0f4
[org-mode.git] / testing / lisp / test-org-table.el
blob8b591144fe306007c8c2a05c8461af949cb5e0f4
1 ;;; test-org-table.el --- tests for org-table.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:
26 (ert-deftest test-org-table/org-table-convert-refs-to-an/1 ()
27 "Simple reference @1$1."
28 (should
29 (string= "A1" (org-table-convert-refs-to-an "@1$1"))))
31 ;; TODO: Test broken
32 ;; (ert-deftest test-org-table/org-table-convert-refs-to-an/2 ()
33 ;; "Self reference @1$1."
34 ;; (should
35 ;; (string= "A1 = $0" (org-table-convert-refs-to-an "@1$1 = $0"))))
37 (ert-deftest test-org-table/org-table-convert-refs-to-an/3 ()
38 "Remote reference."
39 (should
40 (string= "C& = remote(FOO, @@#B&)" (org-table-convert-refs-to-an "$3 = remote(FOO, @@#$2)"))))
42 (ert-deftest test-org-table/org-table-convert-refs-to-rc/1 ()
43 "Simple reference @1$1."
44 (should
45 (string= "@1$1" (org-table-convert-refs-to-rc "A1"))))
47 (ert-deftest test-org-table/org-table-convert-refs-to-rc/2 ()
48 "Self reference $0."
49 (should
50 (string= "@1$1 = $0" (org-table-convert-refs-to-rc "A1 = $0"))))
52 ;; TODO: Test Broken
53 ;; (ert-deftest test-org-table/org-table-convert-refs-to-rc/3 ()
54 ;; "Remote reference."
55 ;; (should
56 ;; (string= "$3 = remote(FOO, @@#$2)" (org-table-convert-refs-to-rc "C& = remote(FOO, @@#B&)"))))
58 (ert-deftest test-org-table/simple-formula ()
59 (org-test-with-temp-text-in-file "
61 * simple formula
62 :PROPERTIES:
63 :ID: 563523f7-3f3e-49c9-9622-9216cc9a5d95
64 :END:
66 #+tblname: simple-formula
67 | 1 |
68 | 2 |
69 | 3 |
70 | 4 |
71 |----|
72 | |
73 #+TBLFM: $1=vsum(@1..@-1)
75 (re-search-forward (regexp-quote "#+tblname: simple-formula") nil t)
76 (forward-line 1)
77 (should (org-at-table-p))
78 (should (org-table-recalculate 'all))
79 (should (string= "10" (first (nth 5 (org-table-to-lisp)))))))
81 (provide 'test-org-table)
83 ;;; test-org-table.el ends here