~ chicken-core (master) /tests/invalid-utf-test.scm
Trap1;;; ensure invalid UTF-8 sequences are reproducibly read and written23(import (chicken io) (chicken irregex) (chicken file))4(import (chicken bytevector) (chicken file posix))56(define in "UTF-8-test.txt")7(define out "UTF-8-test.out")89(when (file-exists? out) (delete-file out))1011(with-input-from-file in12 (lambda ()13 (call-with-output-file out14 (lambda (o)15 (let loop ()16 (let ((line (read-line)))17 (unless (eof-object? line)18 (display line o)19 (newline o)20 (loop)))))21 #:unix))22 #:unix)2324(define sz (file-size in))2526;(assert (= sz (file-size out)))27(let ((old (with-input-from-file in (cut read-bytevector sz) #:binary))28 (new (with-input-from-file out (cut read-bytevector sz) #:binary)))29 (assert (bytevector=? old new)))