diff options
author | Blendoit <blendoit@gmail.com> | 2020-08-01 15:18:40 -0700 |
---|---|---|
committer | Blendoit <blendoit@gmail.com> | 2020-08-01 15:18:40 -0700 |
commit | 374ae3de24187512adddf01a56e5eb52c79db65f (patch) | |
tree | 847adf6824b56394f5a040ba45863e2dbdceac70 /elpa/csv-mode-1.12/csv-mode-tests.el | |
parent | 54fbf6576cf2dd94ef5af332a6075723a9dfa8b3 (diff) |
Include contents of elpa/ sources + theme update.
Diffstat (limited to 'elpa/csv-mode-1.12/csv-mode-tests.el')
-rw-r--r-- | elpa/csv-mode-1.12/csv-mode-tests.el | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/elpa/csv-mode-1.12/csv-mode-tests.el b/elpa/csv-mode-1.12/csv-mode-tests.el new file mode 100644 index 0000000..b5e0b49 --- /dev/null +++ b/elpa/csv-mode-1.12/csv-mode-tests.el @@ -0,0 +1,102 @@ +;;; csv-mode-tests.el --- Tests for CSV mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 Free Software Foundation, Inc + +;; Author: Simen Heggestøyl <simenheg@gmail.com> +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; + +;;; Code: + +(require 'ert) +(require 'csv-mode) +(eval-when-compile (require 'subr-x)) + +(ert-deftest csv-mode-tests-end-of-field () + (with-temp-buffer + (csv-mode) + (insert "aaa,bbb") + (goto-char (point-min)) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) + "aaa")) + (forward-char) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) + "aaa,bbb")))) + +(ert-deftest csv-mode-tests-end-of-field-with-quotes () + (with-temp-buffer + (csv-mode) + (insert "aaa,\"b,b\"") + (goto-char (point-min)) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) + "aaa")) + (forward-char) + (csv-end-of-field) + (should (equal (buffer-substring (point-min) (point)) + "aaa,\"b,b\"")))) + +(ert-deftest csv-mode-tests-beginning-of-field () + (with-temp-buffer + (csv-mode) + (insert "aaa,bbb") + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) + "bbb")) + (backward-char) + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) + "aaa,bbb")))) + +(ert-deftest csv-mode-tests-beginning-of-field-with-quotes () + (with-temp-buffer + (csv-mode) + (insert "aaa,\"b,b\"") + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) + "\"b,b\"")) + (backward-char) + (csv-beginning-of-field) + (should (equal (buffer-substring (point) (point-max)) + "aaa,\"b,b\"")))) + +(defun csv-mode-tests--align-fields (before after) + (with-temp-buffer + (insert (string-join before "\n")) + (csv-align-fields t (point-min) (point-max)) + (should (equal (buffer-string) (string-join after "\n"))))) + +(ert-deftest csv-mode-tests-align-fields () + (csv-mode-tests--align-fields + '("aaa,bbb,ccc" + "1,2,3") + '("aaa, bbb, ccc" + "1 , 2 , 3"))) + +(ert-deftest csv-mode-tests-align-fields-with-quotes () + (csv-mode-tests--align-fields + '("aaa,\"b,b\",ccc" + "1,2,3") + '("aaa, \"b,b\", ccc" + "1 , 2 , 3"))) + +(provide 'csv-mode-tests) +;;; csv-mode-tests.el ends here |