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:
parent
e30ee90478
commit
bc50aff6f8
1 changed files with 20 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue