#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Wed, 27 Mar 2019 14:54:36 +0100
changeset 2188 11bf104c2bdd
parent 2187 40d7bf5c68b4
child 2189 5c1b6dc15541
#QUALITY by cg class: RegressionTests::StreamTests added: #test51_skipSeparators changed: #test50_skipThrough
RegressionTests__StreamTests.st
--- a/RegressionTests__StreamTests.st	Tue Mar 26 18:29:48 2019 +0100
+++ b/RegressionTests__StreamTests.st	Wed Mar 27 14:54:36 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "{ Package: 'stx:goodies/regression' }"
 
 "{ NameSpace: RegressionTests }"
@@ -729,30 +731,212 @@
     |s|
 
          "0123456789012345678901"
-    s := '0123456789012345678901' readStream.
-    self assert:(s position == 0).
-    s skipThrough:$0.
-    self assert:(s peek == $1).
-    self assert:(s position == 1).
-
-    s skipThrough:$0.
-    self assert:(s peek == $1).
-    self assert:(s position == 11).
+    {     
+        '0123456789012345678901' asArray.
+        '0123456789012345678901' asArray asOrderedCollection.
+        '0123456789012345678901' .
+        '0123456789012345678901' asUnicode16String .
+        '0123456789012345678901' asUnicode32String .
+    } do:[:eachInput |    
+        s := eachInput readStream.
+        self assert:(s position == 0).
+        s skipThrough:$0.
+        self assert:(s peek == $1).
+        self assert:(s position == 1).
 
-    s skipThrough:$0.
-    self assert:(s peek == $1).
-    self assert:(s position == 21).
+        s skipThrough:$0.
+        self assert:(s peek == $1).
+        self assert:(s position == 11).
+
+        s skipThrough:$0.
+        self assert:(s peek == $1).
+        self assert:(s position == 21).
 
-    s := 'bla { foo }' readStream.
-    s skipThrough:${.
-    self assert:(s peek == $ ).
-    s skipThrough:$}.
-    self assert:(s atEnd).
-
+        s := 'bla { foo }' readStream.
+        s skipThrough:${.
+        self assert:(s peek == $ ).
+        s skipThrough:$}.
+        self assert:(s atEnd).
+    ].
+    
     "
      self run:#test50_skipThrough
      self new test50_skipThrough
     "
+
+    "Modified: / 27-03-2019 / 14:50:19 / Claus Gittinger"
+!
+
+test51_skipSeparators
+    |s next|
+
+    {   
+        "1234567890123456789"
+        '0   1   2         3' asArray .
+        '0   1   2         3' asArray asOrderedCollection.
+        '0   1   2         3' .
+        '0   1   2         3' asUnicode16String .
+        '0   1   2         3' asUnicode32String .
+    } do:[:eachInput |
+        s := eachInput readStream.
+        next := s skipSeparators.
+        self assert:(s position == 0).
+        self assert:(next == $0).
+        self assert:(s peek == $0).
+        self assert:(s skipSeparators == $0).
+        self assert:(s position == 0).
+        self assert:(s peek == $0).
+        self assert:(s position == 0).
+        self assert:(s next == $0).
+        self assert:(s position == 1).
+
+        next := s skipSeparators.
+        self assert:(s position == 4).
+        self assert:(next == $1).
+        self assert:(s peek == $1).
+        self assert:(s skipSeparators == $1).
+        self assert:(s position == 4).
+        self assert:(s peek == $1).
+        self assert:(s position == 4).
+        self assert:(s next == $1).
+        self assert:(s position == 5).
+        
+        next := s skipSeparators.
+        self assert:(s position == 8).
+        self assert:(next == $2).
+        self assert:(s peek == $2).
+        self assert:(s skipSeparators == $2).
+        self assert:(s position == 8).
+        self assert:(s peek == $2).
+        self assert:(s position == 8).
+        self assert:(s next == $2).
+        self assert:(s position == 9).
+
+        next := s skipSeparators.
+        self assert:(s position == 18).
+        self assert:(next == $3).
+        self assert:(s peek == $3).
+        self assert:(s skipSeparators == $3).
+        self assert:(s position == 18).
+        self assert:(s peek == $3).
+        self assert:(s position == 18).
+        self assert:(s next == $3).
+        self assert:(s position == 19).
+
+        self assert:(s atEnd).
+    ].
+    
+    {   
+        "1234567890123456789"
+        '0                  ' asArray.
+        '0                  ' asArray asOrderedCollection.
+        '0                  ' .
+        '0                  ' asUnicode16String .
+        '0                  ' asUnicode32String .
+    } do:[:eachInput |
+        s := eachInput readStream.
+        next := s skipSeparators.
+        self assert:(s position == 0).
+        self assert:(next == $0).
+        self assert:(s peek == $0).
+        self assert:(s skipSeparators == $0).
+        self assert:(s position == 0).
+        self assert:(s peek == $0).
+        self assert:(s position == 0).
+        self assert:(s next == $0).
+        self assert:(s position == 1).
+
+        next := s skipSeparators.
+        self assert:(s position == 19).
+        self assert:(next isNil).
+        self assert:(s peek isNil).
+        self assert:(s skipSeparators isNil).
+        self assert:(s position == 19).
+        self assert:(s peek isNil).
+        self assert:(s position == 19).
+        self assert:(s next isNil).
+        self assert:(s position == 19).
+        
+        self assert:(s atEnd).
+    ].
+
+    {   
+        "12345678901234567890"
+        '0                  x' asArray.
+        '0                  x' asArray asOrderedCollection.
+        '0                  x' .
+        '0                  x' asUnicode16String .
+        '0                  x' asUnicode32String .
+    } do:[:eachInput |
+        s := eachInput readStream.
+        s readLimit:19.
+        
+        next := s skipSeparators.
+        self assert:(s position == 0).
+        self assert:(next == $0).
+        self assert:(s peek == $0).
+        self assert:(s skipSeparators == $0).
+        self assert:(s position == 0).
+        self assert:(s peek == $0).
+        self assert:(s position == 0).
+        self assert:(s next == $0).
+        self assert:(s position == 1).
+
+        next := s skipSeparators.
+        self assert:(s position == 19).
+        self assert:(next isNil).
+        self assert:(s peek isNil).
+        self assert:(s skipSeparators isNil).
+        self assert:(s position == 19).
+        self assert:(s peek isNil).
+        self assert:(s position == 19).
+        self assert:(s next isNil).
+        self assert:(s position == 19).
+
+        self assert:(s atEnd).
+    ].
+
+    {   
+        "12345678901234567890"
+        '0                   ' asArray.
+        '0                   ' asArray asOrderedCollection.
+        '0                   ' .
+        '0                   ' asUnicode16String .
+        '0                   ' asUnicode32String .
+    } do:[:eachInput |
+        s := eachInput readStream.
+        s readLimit:19.
+
+        next := s skipSeparators.
+        self assert:(s position == 0).
+        self assert:(next == $0).
+        self assert:(s peek == $0).
+        self assert:(s skipSeparators == $0).
+        self assert:(s position == 0).
+        self assert:(s peek == $0).
+        self assert:(s position == 0).
+        self assert:(s next == $0).
+        self assert:(s position == 1).
+
+        next := s skipSeparators.
+        self assert:(s position == 19).
+        self assert:(next isNil).
+        self assert:(s peek isNil).
+        self assert:(s skipSeparators isNil).
+        self assert:(s position == 19).
+        self assert:(s peek isNil).
+        self assert:(s position == 19).
+        self assert:(s next isNil).
+        self assert:(s position == 19).
+
+        self assert:(s atEnd).
+    ].
+    "
+     self run:#test51_skipSeparators
+     self new test51_skipSeparators
+    "
+
+    "Created: / 27-03-2019 / 14:44:14 / Claus Gittinger"
 ! !
 
 !StreamTests class methodsFor:'documentation'!