emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 4fb2abe 29/60: Update simple-csv-parser


From: Junpeng Qiu
Subject: [elpa] master 4fb2abe 29/60: Update simple-csv-parser
Date: Tue, 25 Oct 2016 17:45:14 +0000 (UTC)

branch: master
commit 4fb2abe96221ab4688bdf85681de5c7260a2709f
Author: Junpeng Qiu <address@hidden>
Commit: Junpeng Qiu <address@hidden>

    Update simple-csv-parser
---
 examples/simple-csv-parser-tests.el |   39 +++++++++++++++++++++++++++++++++++
 examples/simple-csv-parser.el       |    8 +++----
 2 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/examples/simple-csv-parser-tests.el 
b/examples/simple-csv-parser-tests.el
new file mode 100644
index 0000000..1cb1e9d
--- /dev/null
+++ b/examples/simple-csv-parser-tests.el
@@ -0,0 +1,39 @@
+;;; simple-csv-parser-tests.el --- Tests for simple csv parser  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2016  Junpeng Qiu
+
+;; Author: Junpeng Qiu <address@hidden>
+;; 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 <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'ert)
+(require 'simple-csv-parser)
+
+(ert-deftest test-simple-csv ()
+  (should
+   (equal
+    (s-parse-csv "a1s,b,d,e,f\na,,c,d,")
+    '(("a1s" "b" "d" "e" "f")
+      ("a" "" "c" "d" "")))))
+
+
+(provide 'simple-csv-parser-tests)
+;;; simple-csv-parser-tests.el ends here
diff --git a/examples/simple-csv-parser.el b/examples/simple-csv-parser.el
index 705717c..c2c55e8 100644
--- a/examples/simple-csv-parser.el
+++ b/examples/simple-csv-parser.el
@@ -24,6 +24,8 @@
 
 ;;; Code:
 
+(require 'parsec)
+
 (defun s-csv-file ()
   (parsec-many (s-csv-line)))
 
@@ -45,12 +47,8 @@
   (parsec-or (parsec-and (parsec-ch ?,) (s-csv-cells)) nil))
 
 (defun s-parse-csv (input)
-  (with-temp-buffer
-    (insert input)
-    (goto-char (point-min))
+  (parsec-with-input input
     (s-csv-file)))
 
-(s-parse-csv "a1s,b,d,e,f")
-
 (provide 'simple-csv-parser)
 ;;; simple-csv-parser.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]