]> gitweb.factorcode.org Git - factor.git/commitdiff
io.streams.peek: test with memory-stream
authorJoe Groff <arcata@gmail.com>
Thu, 13 Oct 2011 22:24:28 +0000 (15:24 -0700)
committerJoe Groff <arcata@gmail.com>
Tue, 18 Oct 2011 04:23:06 +0000 (21:23 -0700)
Some binary stream types use memcpy to implement read-unsafe, while element-agnostic wrapper streams have to use copy. Make sure peek-stream works with both when it has to divide a read between the peek buffer and the underlying buffer (it does).

extra/io/streams/peek/peek-tests.factor

index 8a99206d0fe19f65afe13a150ad4bb5a296593ff..7aa8d3d97729a54eb3135e2cd512934a75e5917f 100644 (file)
@@ -99,3 +99,33 @@ IN: io.streams.peek.tests
         10 swap stream-read ,
     ] { } make
 ] unit-test
+
+[
+    {
+        B{ 0 1 2 3 }
+        B{ 0 1 2 3 4 5 }
+        B{ 0 1 }
+        B{ 2 3 }
+        B{ 4 5 }
+        B{ 6 7 }
+        B{ 8 9 10 11 }
+        B{ 8 9 10 11 12 13 14 15 }
+        B{ 8 9 10 11 12 13 14 15 16 17 }
+    }
+]
+[
+    [
+        [
+            26 iota >byte-array <memory-stream> <peek-stream>
+            4 over stream-peek ,
+            6 over stream-peek ,
+            2 over stream-read ,
+            2 over stream-read ,
+            2 over stream-read ,
+            2 over stream-read ,
+            4 over stream-peek ,
+            8 over stream-peek ,
+            10 swap stream-read ,
+        ] { } make
+    ] with-destructors
+] unit-test