-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added StreamReverseIterator test cases
- Loading branch information
Showing
6 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...k-Stream-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testNextAtMost.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
27 changes: 27 additions & 0 deletions
27
...m-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testReversedDoCollect.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
27 changes: 27 additions & 0 deletions
27
...-Objects-Tests.package/RsRedisStreamIteratorTest.class/instance/testReversedNextAtMost.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
2 changes: 1 addition & 1 deletion
2
repository/RediStick-Stream-Objects.package/RsStream.class/instance/previousAtMost.after..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
repository/RediStick-Stream-Objects.package/RsStreamIterator.class/instance/reversed.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
converting | ||
reversed | ||
^ RsStreamReverseIterator on: self stream from: self currentId |
3 changes: 3 additions & 0 deletions
3
...itory/RediStick-Stream-Objects.package/RsStreamReverseIterator.class/instance/reversed.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
converting | ||
reversed | ||
^ RsStreamIterator on: self stream from: self currentId |