#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Fri, 22 Apr 2016 15:35:47 +0200
changeset 1400 3ba502e13bff
parent 1399 f58dbe20ecff
child 1401 f21e33b07c13
#QUALITY by cg class: RegressionTests::StreamTests added: #test21_readWriteStreamWithPosition changed: #test20_readWriteStream
RegressionTests__StreamTests.st
--- a/RegressionTests__StreamTests.st	Wed Apr 20 13:51:42 2016 +0200
+++ b/RegressionTests__StreamTests.st	Fri Apr 22 15:35:47 2016 +0200
@@ -395,7 +395,12 @@
     self assert:(s contents = 'hello').
     self assert:(s readLimit == 5).
 
-    s nextPutAll:' world'.
+    s nextPut:Character space.
+    self assert:(s position == 6).
+    self assert:(s contents = 'hello ').
+    self assert:(s readLimit == 6).
+
+    s nextPutAll:'world'.
     self assert:(s position == 11).
     self assert:(s contents = 'hello world').
     self assert:(s readLimit == 11).
@@ -421,6 +426,33 @@
     "
 !
 
+test21_readWriteStreamWithPosition
+    |s|
+
+         "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 readLimit == 5).
+
+    s nextPutAll:' world'.
+    self assert:(s position == 11).
+    self assert:(s readLimit == 11).
+
+    s position:(s position - 5).
+    self assert:(s upToEnd = 'world').
+    self assert:(s position = 11).
+    self assert:(s readLimit = 11).
+
+    "
+     self run:#test21_readWriteStreamWithPosition
+     self new test21_readWriteStreamWithPosition
+    "
+!
+
 test30_readWriteBinary
     |testVector s val|