class: RegressionTests::StreamTests
authorClaus Gittinger <cg@exept.de>
Tue, 09 Dec 2014 17:27:25 +0100
changeset 1251 648aad37189b
parent 1250 e428a40b92ce
child 1252 5bc6d5729453
class: RegressionTests::StreamTests added: #test20_readWriteStream
RegressionTests__StreamTests.st
--- a/RegressionTests__StreamTests.st	Thu Dec 04 17:37:27 2014 +0100
+++ b/RegressionTests__StreamTests.st	Tue Dec 09 17:27:25 2014 +0100
@@ -377,6 +377,45 @@
      self run:#test09_writeStreamErrors
      self new test09_writeStreamErrors
     "
+!
+
+test20_readWriteStream
+    |s ch string|
+
+         "0123456789012345678901"
+    s := ReadWriteStream on:(String new).
+    self assert:(s position == 0).
+    self assert:(s readLimit == 0).
+
+    s nextPutAll:'hello'.
+    self assert:(s position == 5).
+    self assert:(s contents = 'hello').
+    self assert:(s readLimit == 5).
+
+    s nextPutAll:' world'.
+    self assert:(s position == 11).
+    self assert:(s contents = 'hello world').
+    self assert:(s readLimit == 11).
+
+    s reset.
+    self assert:(s position == 0).
+    self assert:(s readLimit == 11).
+
+    ch := s next.
+    self assert:(ch == $h).
+    string := s next:4.
+    self assert:(string = 'ello').
+    s reset.
+    self assert:(s position == 0).
+    self assert:(s readLimit == 11).
+
+    string := s upToEnd.
+    self assert:(string = 'hello world').
+
+    "
+     self run:#test20_readWriteStream
+     self new test20_readWriteStream
+    "
 ! !
 
 !StreamTests class methodsFor:'documentation'!