diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-07-01 10:17:51 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-07-01 10:30:45 +0200 |
commit | 79f29b490ea9424cb5a9a1789b7fbdba0cd9b4d8 (patch) | |
tree | c899d26b6793d7d76a06021c29975b9732b0c014 | |
parent | 969daf41ac8a365c6ef82be2d6d0539b1cc6992b (diff) | |
download | org-mode-79f29b490ea9424cb5a9a1789b7fbdba0cd9b4d8.tar.gz |
org-table: Add tests
* testing/lisp/test-org-table.el (test-org-table/move-row-down):
(test-org-table/move-row-up): New tests.
-rw-r--r-- | testing/lisp/test-org-table.el | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 55eacba..e5f5d69 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -2093,6 +2093,92 @@ is t, then new columns should be added as needed" (let ((org-table-tab-jumps-over-hlines nil)) (org-table-next-field)) (buffer-string))))) + + +;;; Moving rows, moving columns + +(ert-deftest test-org-table/move-row-down () + "Test `org-table-move-row-down' specifications." + ;; Error out when row cannot be moved, e.g., it is the last row in + ;; the table. + (should-error + (org-test-with-temp-text "| a |" + (org-table-move-row-down))) + (should-error + (org-test-with-temp-text "| a |\n" + (org-table-move-row-down))) + (should-error + (org-test-with-temp-text "| a |\n| <point>b |" + (org-table-move-row-down))) + ;; Move data lines. + (should + (equal "| b |\n| a |\n" + (org-test-with-temp-text "| a |\n| b |\n" + (org-table-move-row-down) + (buffer-string)))) + (should + (equal "|---|\n| a |\n" + (org-test-with-temp-text "| a |\n|---|\n" + (org-table-move-row-down) + (buffer-string)))) + ;; Move hlines. + (should + (equal "| b |\n|---|\n" + (org-test-with-temp-text "|---|\n| b |\n" + (org-table-move-row-down) + (buffer-string)))) + (should + (equal "|---|\n|---|\n" + (org-test-with-temp-text "|---|\n|---|\n" + (org-table-move-row-down) + (buffer-string)))) + ;; Move rows even without a final newline. + (should + (equal "| b |\n| a |\n" + (org-test-with-temp-text "| a |\n| b |" + (org-table-move-row-down) + (buffer-string))))) + +(ert-deftest test-org-table/move-row-up () + "Test `org-table-move-row-up' specifications." + ;; Error out when row cannot be moved, e.g., it is the first row in + ;; the table. + (should-error + (org-test-with-temp-text "| a |" + (org-table-move-row-up))) + (should-error + (org-test-with-temp-text "| a |\n" + (org-table-move-row-up))) + ;; Move data lines. + (should + (equal "| b |\n| a |\n" + (org-test-with-temp-text "| a |\n| <point>b |\n" + (org-table-move-row-up) + (buffer-string)))) + (should + (equal "| b |\n|---|\n" + (org-test-with-temp-text "|---|\n| <point>b |\n" + (org-table-move-row-up) + (buffer-string)))) + ;; Move hlines. + (should + (equal "|---|\n| a |\n" + (org-test-with-temp-text "| a |\n|<point>---|\n" + (org-table-move-row-up) + (buffer-string)))) + (should + (equal "|---|\n|---|\n" + (org-test-with-temp-text "|---|\n|<point>---|\n" + (org-table-move-row-up) + (buffer-string)))) + ;; Move rows even without a final newline. + (should + (equal "| b |\n| a |\n" + (org-test-with-temp-text "| a |\n| <point>b |" + (org-table-move-row-up) + (buffer-string))))) + + ;;; Miscellaneous |