RegressionTests__StreamTests.st
changeset 2401 b52413a8eca3
parent 2206 827d17b7a941
child 2404 e23a2aec895a
--- a/RegressionTests__StreamTests.st	Wed Sep 18 15:24:23 2019 +0200
+++ b/RegressionTests__StreamTests.st	Wed Sep 18 17:15:25 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "{ Package: 'stx:goodies/regression' }"
 
 "{ NameSpace: RegressionTests }"
@@ -836,6 +838,42 @@
     "Modified: / 27-03-2019 / 14:50:19 / Claus Gittinger"
 !
 
+test50b_through
+    |s|
+
+        "0123456789012345678901"
+    {   "          1         2 "
+        '0123456789012345678901' .
+        '0123456789012345678901' asUnicode16String .
+        '0123456789012345678901' asUnicode32String .
+    } do:[:eachInput |
+        |r|
+
+        s := eachInput readStream.
+
+        self assert:(s position == 0).
+        r := s through:$9.
+        self assert:(s peek == $0).
+        self assert:(s position == 10).
+        self assert:(r = '0123456789').
+
+        r := s through:$9.
+        self assert:(s peek == $0).
+        self assert:(s position == 20).
+        self assert:(r = '0123456789').
+
+        r := s through:$9.
+        self assert:(s peek isNil).
+        self assert:(s atEnd).
+        self assert:(r = '01').
+    ].
+    
+    "
+     self run:#test50b_through
+     self new test50b_through
+    "
+!
+
 test51_skipSeparators
     |s next|
 
@@ -1066,6 +1104,38 @@
      self run:#test52_skipThroughAll
      self new test52_skipThroughAll
     "
+!
+
+test52b_throughAll
+    |s|
+
+        "0123456789012345678901"
+    {   "          1         2 "
+        '0123456789012345678901' .
+        '0123456789012345678901' asUnicode16String .
+        '0123456789012345678901' asUnicode32String .
+    } do:[:eachInput |
+        |r|
+
+        s := eachInput readStream.
+
+        self assert:(s position == 0).
+        r := s throughAll:'901'.
+        self assert:(s peek == $2).
+        self assert:(s position == 12).
+        self assert:(r = '012345678901').
+
+        r := s throughAll:'901'.
+        self assert:(s peek isNil).
+        self assert:(s atEnd).
+        self assert:(s position == 22).
+        self assert:(r = '2345678901').
+    ].
+    
+    "
+     self run:#test52b_throughAll
+     self new test52b_throughAll
+    "
 ! !
 
 !StreamTests class methodsFor:'documentation'!