1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

Add tests for get-bytevector-some!

* test-suite/tests/r6rs-ports.test (get-bytevector-n! [short]): add
  (get-bytevector-n! [long]): add
This commit is contained in:
Andrew Whatson 2021-01-22 20:10:09 +10:00 committed by Andy Wingo
parent e30ee90478
commit bc50aff6f8

View file

@ -23,6 +23,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (ice-9 match)
#:use-module ((ice-9 binary-ports) #:select (get-bytevector-some!))
#:use-module (rnrs io ports)
#:use-module (rnrs io simple)
#:use-module (rnrs exceptions)
@ -183,6 +184,25 @@
(equal? (bytevector->u8-list bv)
(map char->integer (string->list str))))))
(pass-if "get-bytevector-some! [short]"
(let* ((port (open-input-string "GNU Guile"))
(bv (make-bytevector 4))
(read (get-bytevector-some! port bv 0 4)))
(and (equal? read 4)
(equal? (bytevector->u8-list bv)
(map char->integer (string->list "GNU "))))))
(pass-if "get-bytevector-some! [long]"
(let* ((str "GNU Guile")
(port (open-input-string str))
(bv (make-bytevector 256))
(read (get-bytevector-some! port bv 0 256)))
(and (equal? read (string-length str))
(equal? (map (lambda (i)
(bytevector-u8-ref bv i))
(iota read))
(map char->integer (string->list str))))))
(pass-if "get-bytevector-all"
(let* ((str "GNU Guile")
(index 0)