Skip to content

Commit

Permalink
Added testContentsFrom and testContentsReversedFrom test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mumez committed Oct 8, 2024
1 parent 2e6e0a0 commit 3a8ac04
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
tests
testComing

| strm strm2 nextComing nextThree |
strm := self newStreamNamed: 'testComing'.
strm2 := self newStreamNamed: 'testComing'.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tests
testContentsFrom
| strm conts fifteen fifteenToLast seventeen fifteenToSeventeen eighteenToLast |
strm := self newStreamNamed: 'testContentsFrom'.
strm trimTo: 0.
self assert: strm length equals: 0.
1 to: 20 do: [ :idx |
strm nextPut: idx -> idx.
].
conts := strm contents.
self assert: conts size equals: 20.
fifteen := conts at: 15.
fifteenToLast := strm contentsFrom: fifteen id.

self assert: fifteenToLast size equals: 6.
self assert: conts last content equals: fifteenToLast last content.

seventeen := conts at: 17.
fifteenToSeventeen := strm contentsFrom: fifteen id to: seventeen id.

self assert: fifteenToSeventeen size equals: 3.
self assert: fifteenToLast first content equals: fifteenToSeventeen first content.

self assert: (strm contentAt: seventeen id) content equals: '17'->'17'.

eighteenToLast := strm contentsNextFrom: seventeen id count: 3.
self assert: eighteenToLast size equals: 3.
self assert: conts last content equals: eighteenToLast last content.

strm trimTo: 0.
self assert: strm length equals: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tests
testContentsReversedFrom
| strm conts fifteen fifteenToFirst seventeen seventeenToFifteen sixteenToFifteen |
strm := self newStreamNamed: 'testContentsReversedFrom'.
strm trimTo: 0.
self assert: strm length equals: 0.
1 to: 20 do: [ :idx |
strm nextPut: idx -> idx.
].
conts := strm contentsReversed.
self assert: conts size equals: 20.
fifteen := conts at: 6.
fifteenToFirst := strm contentsReversedFrom: fifteen id.

self assert: fifteenToFirst size equals: 15.
self assert: conts last content equals: fifteenToFirst last content.

seventeen := conts at: 4.
seventeenToFifteen := strm contentsReversedFrom: seventeen id to: fifteen id.

self assert: seventeenToFifteen size equals: 3.
self assert: fifteenToFirst first content equals: seventeenToFifteen last content.

self assert: (strm contentAt: seventeen id) content equals: '17'->'17'.

sixteenToFifteen := strm contentsReversedNextFrom: seventeen id count: 2.
self assert: sixteenToFifteen size equals: 2.
self assert: fifteenToFirst first content equals: sixteenToFifteen last content.

strm trimTo: 0.
self assert: strm length equals: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
reading
contentsReversedFrom: fromMessageId
^ self contentsReversedFrom: fromMessageId to: RsStreamMessageId min

0 comments on commit 3a8ac04

Please sign in to comment.