test-org-table.el 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ;;; test-org-table.el
  2. ;; Copyright (c) ߛ David Maus
  3. ;; Authors: David Maus
  4. ;; Released under the GNU General Public License version 3
  5. ;; see: http://www.gnu.org/licenses/gpl-3.0.html
  6. ;;;; Comments:
  7. ;; Template test file for Org-mode tests
  8. ;;; Code:
  9. (let ((load-path (cons (expand-file-name
  10. ".." (file-name-directory
  11. (or load-file-name buffer-file-name)))
  12. load-path)))
  13. (require 'org-test)
  14. (require 'org-test-ob-consts))
  15. ;;; Tests
  16. (ert-deftest test-org-table/org-table-convert-refs-to-an/1 ()
  17. "Simple reference @1$1."
  18. (should
  19. (string= "A1" (org-table-convert-refs-to-an "@1$1"))))
  20. ;; TODO: Test broken
  21. ;; (ert-deftest test-org-table/org-table-convert-refs-to-an/2 ()
  22. ;; "Self reference @1$1."
  23. ;; (should
  24. ;; (string= "A1 = $0" (org-table-convert-refs-to-an "@1$1 = $0"))))
  25. (ert-deftest test-org-table/org-table-convert-refs-to-an/3 ()
  26. "Remote reference."
  27. (should
  28. (string= "C& = remote(FOO, @@#B&)" (org-table-convert-refs-to-an "$3 = remote(FOO, @@#$2)"))))
  29. (ert-deftest test-org-table/org-table-convert-refs-to-rc/1 ()
  30. "Simple reference @1$1."
  31. (should
  32. (string= "@1$1" (org-table-convert-refs-to-rc "A1"))))
  33. (ert-deftest test-org-table/org-table-convert-refs-to-rc/2 ()
  34. "Self reference $0."
  35. (should
  36. (string= "@1$1 = $0" (org-table-convert-refs-to-rc "A1 = $0"))))
  37. ;; TODO: Test Broken
  38. ;; (ert-deftest test-org-table/org-table-convert-refs-to-rc/3 ()
  39. ;; "Remote reference."
  40. ;; (should
  41. ;; (string= "$3 = remote(FOO, @@#$2)" (org-table-convert-refs-to-rc "C& = remote(FOO, @@#B&)"))))
  42. (ert-deftest test-org-table/simple-formula ()
  43. (org-test-with-temp-text-in-file "
  44. * simple formula
  45. :PROPERTIES:
  46. :ID: 563523f7-3f3e-49c9-9622-9216cc9a5d95
  47. :END:
  48. #+tblname: simple-formula
  49. | 1 |
  50. | 2 |
  51. | 3 |
  52. | 4 |
  53. |----|
  54. | |
  55. #+TBLFM: $1=vsum(@1..@-1)
  56. "
  57. (progn
  58. (re-search-forward (regexp-quote "#+tblname: simple-formula") nil t)
  59. (forward-line 1)
  60. (should (org-at-table-p))
  61. (should (org-table-recalculate 'all))
  62. (should (string= "10" (first (nth 5 (org-table-to-lisp))))))))
  63. (provide 'test-org-table)
  64. ;;; test-org-table.el ends here