test-org-table.el 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. (ert-deftest test-org-table/org-table-convert-refs-to-an/1 ()
  10. "Simple reference @1$1."
  11. (should
  12. (string= "A1" (org-table-convert-refs-to-an "@1$1"))))
  13. ;; TODO: Test broken
  14. ;; (ert-deftest test-org-table/org-table-convert-refs-to-an/2 ()
  15. ;; "Self reference @1$1."
  16. ;; (should
  17. ;; (string= "A1 = $0" (org-table-convert-refs-to-an "@1$1 = $0"))))
  18. (ert-deftest test-org-table/org-table-convert-refs-to-an/3 ()
  19. "Remote reference."
  20. (should
  21. (string= "C& = remote(FOO, @@#B&)" (org-table-convert-refs-to-an "$3 = remote(FOO, @@#$2)"))))
  22. (ert-deftest test-org-table/org-table-convert-refs-to-rc/1 ()
  23. "Simple reference @1$1."
  24. (should
  25. (string= "@1$1" (org-table-convert-refs-to-rc "A1"))))
  26. (ert-deftest test-org-table/org-table-convert-refs-to-rc/2 ()
  27. "Self reference $0."
  28. (should
  29. (string= "@1$1 = $0" (org-table-convert-refs-to-rc "A1 = $0"))))
  30. ;; TODO: Test Broken
  31. ;; (ert-deftest test-org-table/org-table-convert-refs-to-rc/3 ()
  32. ;; "Remote reference."
  33. ;; (should
  34. ;; (string= "$3 = remote(FOO, @@#$2)" (org-table-convert-refs-to-rc "C& = remote(FOO, @@#B&)"))))
  35. (ert-deftest test-org-table/simple-formula ()
  36. (org-test-with-temp-text-in-file "
  37. * simple formula
  38. :PROPERTIES:
  39. :ID: 563523f7-3f3e-49c9-9622-9216cc9a5d95
  40. :END:
  41. #+tblname: simple-formula
  42. | 1 |
  43. | 2 |
  44. | 3 |
  45. | 4 |
  46. |----|
  47. | |
  48. #+TBLFM: $1=vsum(@1..@-1)
  49. "
  50. (progn
  51. (re-search-forward (regexp-quote "#+tblname: simple-formula") nil t)
  52. (forward-line 1)
  53. (should (org-at-table-p))
  54. (should (org-table-recalculate 'all))
  55. (should (string= "10" (first (nth 5 (org-table-to-lisp))))))))
  56. (provide 'test-org-table)
  57. ;;; test-org-table.el ends here