guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/03: Add tests for get-bytevector-some!


From: Andy Wingo
Subject: [Guile-commits] 01/03: Add tests for get-bytevector-some!
Date: Fri, 12 Mar 2021 16:32:17 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit bc50aff6f8b16db7b099daf6cdc192f4de7b5fe0
Author: Andrew Whatson <whatson@gmail.com>
AuthorDate: Fri Jan 22 20:10:09 2021 +1000

    Add tests for get-bytevector-some!
    
    * 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 4d1981d..c427834 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]