test-org-table.el 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ;;; test-org-table.el --- tests for org-table.el
  2. ;; Copyright (c) David Maus
  3. ;; Authors: David Maus
  4. ;; This file is not part of GNU Emacs.
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;;; Comments:
  16. ;; Template test file for Org-mode tests
  17. ;;; Code:
  18. (ert-deftest test-org-table/org-table-convert-refs-to-an/1 ()
  19. "Simple reference @1$1."
  20. (should
  21. (string= "A1" (org-table-convert-refs-to-an "@1$1"))))
  22. ;; TODO: Test broken
  23. ;; (ert-deftest test-org-table/org-table-convert-refs-to-an/2 ()
  24. ;; "Self reference @1$1."
  25. ;; (should
  26. ;; (string= "A1 = $0" (org-table-convert-refs-to-an "@1$1 = $0"))))
  27. (ert-deftest test-org-table/org-table-convert-refs-to-an/3 ()
  28. "Remote reference."
  29. (should
  30. (string= "C& = remote(FOO, @@#B&)" (org-table-convert-refs-to-an "$3 = remote(FOO, @@#$2)"))))
  31. (ert-deftest test-org-table/org-table-convert-refs-to-rc/1 ()
  32. "Simple reference @1$1."
  33. (should
  34. (string= "@1$1" (org-table-convert-refs-to-rc "A1"))))
  35. (ert-deftest test-org-table/org-table-convert-refs-to-rc/2 ()
  36. "Self reference $0."
  37. (should
  38. (string= "@1$1 = $0" (org-table-convert-refs-to-rc "A1 = $0"))))
  39. ;; TODO: Test Broken
  40. ;; (ert-deftest test-org-table/org-table-convert-refs-to-rc/3 ()
  41. ;; "Remote reference."
  42. ;; (should
  43. ;; (string= "$3 = remote(FOO, @@#$2)" (org-table-convert-refs-to-rc "C& = remote(FOO, @@#B&)"))))
  44. (ert-deftest test-org-table/simple-formula ()
  45. (org-test-with-temp-text-in-file "
  46. * simple formula
  47. :PROPERTIES:
  48. :ID: 563523f7-3f3e-49c9-9622-9216cc9a5d95
  49. :END:
  50. #+tblname: simple-formula
  51. | 1 |
  52. | 2 |
  53. | 3 |
  54. | 4 |
  55. |----|
  56. | |
  57. #+TBLFM: $1=vsum(@1..@-1)
  58. "
  59. (re-search-forward (regexp-quote "#+tblname: simple-formula") nil t)
  60. (forward-line 1)
  61. (should (org-at-table-p))
  62. (should (org-table-recalculate 'all))
  63. (should (string= "10" (first (nth 5 (org-table-to-lisp)))))))
  64. (provide 'test-org-table)
  65. ;;; test-org-table.el ends here