* [PATCH 1/2] Add tests for get-bytevector-some!
@ 2021-01-22 10:10 Andrew Whatson
2021-01-22 10:10 ` [PATCH 2/2] Fix suspendable implementation of 'get-bytevector-some!' Andrew Whatson
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Whatson @ 2021-01-22 10:10 UTC (permalink / raw)
To: guile-devel; +Cc: Andrew Whatson
* test-suite/tests/r6rs-ports.test (get-bytevector-n! [short]): add
(get-bytevector-n! [long]): add
---
test-suite/tests/r6rs-ports.test | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
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)
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] Fix suspendable implementation of 'get-bytevector-some!'
2021-01-22 10:10 [PATCH 1/2] Add tests for get-bytevector-some! Andrew Whatson
@ 2021-01-22 10:10 ` Andrew Whatson
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Whatson @ 2021-01-22 10:10 UTC (permalink / raw)
To: guile-devel; +Cc: Andrew Whatson
* module/ice-9/suspendable-ports.scm (get-bytevector-some!): Fix
incorrect arguments to bytevector-copy!
---
module/ice-9/suspendable-ports.scm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/module/ice-9/suspendable-ports.scm b/module/ice-9/suspendable-ports.scm
index f5f005cca..a823f1d37 100644
--- a/module/ice-9/suspendable-ports.scm
+++ b/module/ice-9/suspendable-ports.scm
@@ -338,7 +338,7 @@
the-eof-object)
(let ((transfer-size (min count buffered)))
(bytevector-copy! (port-buffer-bytevector buf) cur
- transfer-size start buffered)
+ bv start transfer-size)
(set-port-buffer-cur! buf (+ cur transfer-size))
transfer-size))))))
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-22 10:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 10:10 [PATCH 1/2] Add tests for get-bytevector-some! Andrew Whatson
2021-01-22 10:10 ` [PATCH 2/2] Fix suspendable implementation of 'get-bytevector-some!' Andrew Whatson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).