1(import (edward util)2 (only (srfi 1) iota)3 (only (chicken file posix) port->fileno))45(test-group "ports->lines"6 (test "multiple"7 '(("foo" "bar" "baz") . 12)8 (let ((port (open-input-string "foo\nbar\nbaz\n")))9 (port->lines port)))1011 (test "empty"12 '(() . 0)13 (let ((port (open-input-string "")))14 (port->lines port))))1516(test-group "count-bytes"17 (test "ascii string" 6 (count-bytes "foobar"))18 (test "multibyte string" 2 (count-bytes "λ")))1920(test-group "path-join"21 (test "empty" "" (path-join))22 (test "single" "foo" (path-join "foo"))23 (test "multiple" "foo/bar/baz" (path-join "foo" "bar" "baz")))2425;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2627(define (call-with-input-fileno path proc)28 (call-with-input-file29 path30 (lambda (port)31 (proc (port->fileno port)))))3233(test-group "file-read-char"34 (test "read single ascii character"35 #\f36 (call-with-input-fileno "testdata/ascii.txt"37 (lambda (fileno)38 (file-read-char fileno))))39 (test "read end-of-file"40 #f41 (call-with-input-fileno "testdata/empty.txt"42 (lambda (fileno)43 (file-read-char fileno))))44 ;; TODO: Test reading past EOF.45 (test "read multiple characters"46 (list #\f #\o #\o #\newline #f)47 (call-with-input-fileno "testdata/ascii.txt"48 (lambda (fileno)49 (map (lambda (n)50 (file-read-char fileno))51 (iota 5)))))52 (test "read multibyte sequence"53 #\λ54 (call-with-input-fileno "testdata/lambda.txt"55 (lambda (fileno)56 (file-read-char fileno))))57 (test-error "invalid multibyte sequence"58 (call-with-input-fileno "testdata/invalid-utf8-multibyte.txt"59 (lambda (fileno)60 (file-read-char fileno)))))