*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Tue, 19 Feb 2002 18:06:44 +0100
changeset 148 7f97a9cfc234
parent 147 ad483efa672a
child 149 8115618b0874
*** empty log message ***
ReadStreamTest.st
--- a/ReadStreamTest.st	Thu Jan 10 01:56:16 2002 +0100
+++ b/ReadStreamTest.st	Tue Feb 19 18:06:44 2002 +0100
@@ -41,15 +41,32 @@
 checkReadStreamFor:testCollection 
     "check for correct common behavior of Stream reading"
 
+    "The stream is opened in a way so that it can be used for both
+     ReadStreams and ReadWriteStreams. Do not use #on:!!"
+
+    ^ self checkReadStreamFor:testCollection useWith:true
+!
+
+checkReadStreamFor:testCollection useWith:useWith
+    "check for correct common behavior of Stream reading"
+
     |stream|
 
     "The stream is opened in a way so that it can be used for both
      ReadStreams and ReadWriteStreams. Do not use #on:!!"
 
-    stream := self streamClass with:testCollection.
+    useWith ifTrue:[
+        stream := self streamClass with:testCollection.
+    ] ifFalse:[
+        stream := self streamClass on:testCollection.
+    ].
     stream reset. "for ReadWriteStreams"
     self assert:(stream size == testCollection size).
-    self assert:(stream isEmpty not).
+    testCollection size == 0 ifTrue:[
+        self assert:(stream isEmpty).
+    ] ifFalse:[
+        self assert:(stream isEmpty not).
+    ].
     testCollection 
         keysAndValuesDo:[:pos :element | 
             self assert:(stream atEnd not).
@@ -73,7 +90,7 @@
 !ReadStreamTest methodsFor:'setup'!
 
 setUp
-    self streamClass:Rel5::ReadStream
+    self streamClass:Rel5::ReadStream.
 !
 
 streamClass:aClass 
@@ -106,12 +123,19 @@
 
 testReadStream
 
+   self checkReadStreamFor:''.
    self checkReadStreamFor:'12345'.
    self checkReadStreamFor:'12345'asByteArray.
    self checkReadStreamFor:#[1 2 3 4 5].
    self checkReadStreamFor:#(1 2 3 4 5).
    self checkReadStreamFor:#(1 2 3 4 5) asOrderedCollection.
 
+   self checkReadStreamFor:''                                   useWith:false.
+   self checkReadStreamFor:'12345'                              useWith:false.
+   self checkReadStreamFor:'12345'asByteArray                   useWith:false.
+   self checkReadStreamFor:#[1 2 3 4 5]                         useWith:false.
+   self checkReadStreamFor:#(1 2 3 4 5)                         useWith:false.
+   self checkReadStreamFor:#(1 2 3 4 5) asOrderedCollection     useWith:false.
 
    "
     (self selector:#testReadStream) runCase
@@ -180,6 +204,25 @@
 
     stream := self streamClass with:'12345'.
     self assert:(stream position == (startPosition+5)).
+!
+
+xxtestReadBinary
+    |stream byte|
+
+    stream := self streamClass on:'hello'.
+    stream binary.
+
+    self assert:(byte := stream next) == $h asciiValue.
+    self assert:(byte := stream next) == $e asciiValue.
+    self assert:(byte := stream next) == $l asciiValue.
+    self assert:(byte := stream next) == $l asciiValue.
+    self assert:(byte := stream next) == $o asciiValue.
+    self assert:(stream atEnd)
+
+
+   "
+    (self selector:#testReadBinary) runCase
+   "
 ! !
 
 !ReadStreamTest class methodsFor:'documentation'!