diff options
author | Andrew Whatson <whatson@gmail.com> | 2021-01-22 20:10:09 +1000 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2021-03-12 22:11:51 +0100 |
commit | bc50aff6f8b16db7b099daf6cdc192f4de7b5fe0 (patch) | |
tree | 16767b2f4c54ad8ada71d229a33e9c55c5cba4a0 | |
parent | e30ee9047845751615ca6726e22b67aa9b38e187 (diff) | |
download | guile-bc50aff6f8b16db7b099daf6cdc192f4de7b5fe0.tar.gz |
Add tests for get-bytevector-some!
* test-suite/tests/r6rs-ports.test (get-bytevector-n! [short]): add
(get-bytevector-n! [long]): add
-rw-r--r-- | test-suite/tests/r6rs-ports.test | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test index 4d1981df2..c42783465 100644 --- a/test-suite/tests/r6rs-ports.test +++ b/test-suite/tests/r6rs-ports.test @@ -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) |