068-read-bytes-multi.scm (783B)
1 ; Force read-bytes through multiple refill! cycles. BUFSIZE is 4096, so 2 ; reading 5000 bytes in one read-bytes call requires 2 refills. Build 3 ; the payload in-process and roundtrip it through write-bytes/read-bytes 4 ; so the test stays self-contained (no shell or external file generators). 5 (define path "/tmp/scheme1-read-bytes-multi.bin") 6 (define payload (make-bytevector 5000 65)) ; 5000 'A' bytes 7 8 (define op (open-output path)) 9 (if (not (car op)) (exit 10) 0) 10 (write-bytes (cdr op) payload) 11 (close (cdr op)) 12 13 (define ip (open-input path)) 14 (if (not (car ip)) (exit 20) 0) 15 (define rd (read-bytes (cdr ip) 5000)) 16 (close (cdr ip)) 17 (if (not (car rd)) (exit 30) 0) 18 19 (if (and (= (bytevector-length (cdr rd)) 5000) 20 (bytevector=? (cdr rd) payload)) 21 (exit 0) 22 (exit 40))