Add csv simple tests.

This commit is contained in:
Dominik Pantůček 2023-03-30 12:39:20 +02:00
parent a00b0f6239
commit a9c21c6cb0
3 changed files with 19 additions and 3 deletions

View file

@ -29,13 +29,15 @@
csv-simple
(
csv-parse
csv-simple-tests!
)
(import scheme
(chicken base)
(chicken keyword)
(chicken io)
(chicken irregex))
(chicken irregex)
testing)
;; Curry version of line parser with configurable cell separator and
;; string delimiter. Returns a list of lists of strings.
@ -84,5 +86,17 @@
(csv-parse-line (make-csv-line-parser separator string-delimiter)))
(map csv-parse-line lines)))
;; Module self-tests
(define (csv-simple-tests!)
(run-tests
csv-simple
(test-equal? csv-parse-line
((make-csv-line-parser ";" "\"") "test;2;3")
'("test" "2" "3"))
(test-equal? csv-parse-line
((make-csv-line-parser ";" "\"") "test;\"2;quoted\";3")
'("test" "2;quoted" "3"))
))
)