Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added testContentsFrom and testContentsReversedFrom test cases #58

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 @@
reading
contentAt: aMessageId
| conts |
conts := self contentsFrom: aMessageId to: aMessageId.
conts ifEmpty: [ ^ nil ].
^ conts first
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
reading
contentsReversedFrom: fromMessageId
^ self contentsReversedFrom: fromMessageId to: RsStreamMessageId min
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
private
fallbackId
^ self stream first id
^ self stream first
ifNotNil: [ :first | first id ]
ifNil: [ RsStreamMessageId zero ]
Loading