Test output for csv-xml [ok]
Testing time: 3s
/home/mario/local/chicken-4.8.0.3/bin/csi -script run.scm < /dev/null ;;; BEGIN "csv" TESTS ;; DEFINE: define an ascii CR char (define cr (string (integer->char 13))) ;; DEFINE: define an ascii LF char (define lf (string (integer->char 10))) ;; 1. simple (csv->list (string-append "a" lf "b" lf "c" lf "d" lf "")) ;; ==> (("a") ("b") ("c") ("d")) ;; Passed. ;; 2. simple (csv->list (string-append " a " lf " b " lf " c " lf " d " lf "")) ;; ==> ((" a ") (" b ") (" c ") (" d ")) ;; Passed. ;; 3. simple (csv->list (string-append "aaa,bbb,ccc" cr lf "1,2,3" cr lf)) ;; ==> (("aaa" "bbb" "ccc") ("1" "2" "3")) ;; Passed. ;; 4. quoted field (csv->list "aaa,\"bbb\",ccc") ;; ==> (("aaa" "bbb" "ccc")) ;; Passed. ;; 5. quoted field with comma (csv->list "aaa,\"bbb,bbb\",ccc") ;; ==> (("aaa" "bbb,bbb" "ccc")) ;; Passed. ;; 6. quoted field followed by whitespace (csv->list "aaa,\"bbb\" ,ccc") ;; ==> (("aaa" "bbb" "ccc")) ;; Passed. ;; 7. quoted field with newline in it (csv->list (string-append "aaa,\"b" lf "b\",ccc" lf "ddd,eee,fff" lf)) ;; ==> (("aaa" "b\nb" "ccc") ("ddd" "eee" "fff")) ;; Passed. ;; 8. quoted field with doubling escape in middle (csv->list "aaa,\"b\"\"b\",ccc") ;; ==> (("aaa" "b\"b" "ccc")) ;; Passed. ;; 9. quoted field with doubling escape at beginning (csv->list "aaa,\"\"\"bbb\",ccc") ;; ==> (("aaa" "\"bbb" "ccc")) ;; Passed. ;; 10. quoted field with doubling escape at end (csv->list "aaa,\"bbb\"\"\",ccc") ;; ==> (("aaa" "bbb\"" "ccc")) ;; Passed. ;; 11. quoted field with unterminated quote (csv->list "aaa,\"bbb,ccc") ;; ==> (("aaa" "bbb,ccc")) ;; Passed. ;; 12. quoted field followed by eof (csv->list "aaa,\"bbb\"") ;; ==> (("aaa" "bbb")) ;; Passed. ;; DEFINE: define a reader-maker that strips whitespace (define make-ws-stripping-reader (make-csv-reader-maker (quote ((strip-leading-whitespace? . #t) (strip-trailing-whitespace? . #t))))) ;; 13. whitespace strip on simple row terminated by eof (csv->list (make-ws-stripping-reader " a , b , c ")) ;; ==> (("a" "b" "c")) ;; Passed. ;; DEFINE: define a newline-adapting reader-maker (define make-nl-adapt-reader (make-csv-reader-maker (quote ((newline-type . adapt))))) ;; 14. try newline-adapting reader-maker first time (csv->list (make-nl-adapt-reader (string-append "aaa,bbb" lf "ccc" cr ",ddd" cr lf "eee,fff"))) ;; ==> (("aaa" "bbb") ("ccc\r" "ddd\r") ("eee" "fff")) ;; Passed. ;; 15. try newline-adapting reader-maker second time (csv->list (make-nl-adapt-reader (string-append "aaa,bbb" cr lf "ccc" cr ",ddd" lf cr lf "eee,fff" cr lf))) ;; ==> (("aaa" "bbb") ("ccc\r" "ddd\n") ("eee" "fff")) ;; Passed. ;; DEFINE: define an input string with pound char (define str (string-append "a,b,c" lf "#d,e,f" lf "g,h,i" lf)) ;; DEFINE: define reader-maker with pound as comment char (define make-reader-with-pound-quote (make-csv-reader-maker (quote ((comment-chars #\#))))) ;; 16. read str without pound as comment char (csv->list str) ;; ==> (("a" "b" "c") ("#d" "e" "f") ("g" "h" "i")) ;; Passed. ;; 17. read str with pound as comment char (csv->list (make-reader-with-pound-quote str)) ;; ==> (("a" "b" "c") ("g" "h" "i")) ;; Passed. ;; 18. csv->sxml without row and column names (csv->sxml (string-append "aaa,bbb,ccc" cr lf "1,2,3" cr lf)) ;; ==> (*TOP* (row (col-0 "aaa") (col-1 "bbb") (col-2 "ccc")) (row (col-0 "1") (col-1 "2") (col-2 "3"))) ;; Passed. ;; 19. csv->sxml with row and column names (csv->sxml (string-append "aaa,bbb,ccc" cr lf "1,2,3" cr lf) (quote foo) (quote (first second third))) ;; ==> (*TOP* (foo (first "aaa") (second "bbb") (third "ccc")) (foo (first "1") (second "2") (third "3"))) ;; Passed. ;;; END "csv" TESTS: PASSED ;;; (Total: 19 Passed: 19 Failed: 0)