Skip to content

Commit

Permalink
Added StreamReverseIterator test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mumez committed Jul 23, 2024
1 parent 4829932 commit ba246d6
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
tests
testNextAtMost
| strm one two three four five ite1 entries1 ite2 entries2 |
strm := self newStreamNamed: 'testNextAtMost'.
strm trimTo: 0.
self assert: strm length equals: 0.
one := 'one' -> '1'.
two := 'two' -> '2'.
three := 'three' -> '3'.
four := 'four' -> '4'.
five := 'five' -> '5'.
strm << one << two << three << four << five.
ite1 := strm iteratorFromFirst.
self assert: strm first content equals: one.
entries1 := OrderedCollection new.
ite1 nextAtMost: 2 do: [ :each | entries1 add: each ].
self assert: entries1 size equals: 2.
self assert: entries1 first content equals: two.
self assert: entries1 second content equals: three.
ite2 := strm iteratorFrom: entries1 second.
entries2 := OrderedCollection new.
ite2 nextAtMost: 5 do: [ :each | entries2 add: each ].
self assert: entries2 size equals: 2.
self assert: entries2 first content equals: four.
self assert: entries2 last content equals: five.
strm trimTo: 0.
self assert: strm length equals: 0.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
tests
testReversedDoCollect
| strm one two three four five ite1 entries1 ite2 entries2 |
strm := self newStreamNamed: 'testReversedDoCollect'.
strm trimTo: 0.
self assert: strm length equals: 0.
one := 'one' -> '1'.
two := 'two' -> '2'.
three := 'three' -> '3'.
four := 'four' -> '4'.
five := 'five' -> '5'.
strm << one << two << three << four << five.
ite1 := strm iteratorFromLast reversed.
self assert: strm last content equals: five.
entries1 := OrderedCollection new.
ite1 do: [ :each | entries1 add: each ].
self assert: entries1 size equals: 4.
self assert: entries1 first content equals: four.
self assert: entries1 second content equals: three.
self assert: entries1 last content equals: one.
ite2 := (strm iteratorFrom: entries1 second) reversed.
entries2 := ite2 collect: [ :each | each ].
self assert: entries2 size equals: 2.
self assert: entries2 first content equals: two.
self assert: entries2 last content equals: one.
strm trimTo: 0.
self assert: strm length equals: 0.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
tests
testReversedNextAtMost
| strm one two three four five ite1 entries1 ite2 entries2 |
strm := self newStreamNamed: 'testReversedNextAtMost'.
strm trimTo: 0.
self assert: strm length equals: 0.
one := 'one' -> '1'.
two := 'two' -> '2'.
three := 'three' -> '3'.
four := 'four' -> '4'.
five := 'five' -> '5'.
strm << one << two << three << four << five.
ite1 := strm iteratorFromLast reversed.
self assert: strm last content equals: five.
entries1 := OrderedCollection new.
ite1 nextAtMost: 2 do: [ :each | entries1 add: each ].
self assert: entries1 size equals: 2.
self assert: entries1 first content equals: four.
self assert: entries1 second content equals: three.
ite2 := (strm iteratorFrom: entries1 second) reversed.
entries2 := OrderedCollection new.
ite2 nextAtMost: 5 do: [ :each | entries2 add: each ].
self assert: entries2 size equals: 2.
self assert: entries2 first content equals: two.
self assert: entries2 last content equals: one.
strm trimTo: 0.
self assert: strm length equals: 0.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
reading
previousAtMost: count after: latestMessageId
^ self endpoint xRevRange: self name from: latestMessageId count: count
^ self endpoint xRevRange: self name nextFrom: latestMessageId count: count
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
converting
reversed
^ RsStreamReverseIterator on: self stream from: self currentId
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
converting
reversed
^ RsStreamIterator on: self stream from: self currentId

0 comments on commit ba246d6

Please sign in to comment.