From 3a8ac04b98c551706ea215e3857c9aa9b2329296 Mon Sep 17 00:00:00 2001 From: Masashi Umezawa Date: Tue, 8 Oct 2024 23:50:01 +0900 Subject: [PATCH] Added testContentsFrom and testContentsReversedFrom test cases --- .../instance/testComing.st | 1 - .../instance/testContentsFrom.st | 31 +++++++++++++++++++ .../instance/testContentsReversedFrom.st | 31 +++++++++++++++++++ .../instance/contentsReversedFrom..st | 3 ++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsFrom.st create mode 100644 repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsReversedFrom.st create mode 100644 repository/RediStick-Stream-Objects.package/RsStream.class/instance/contentsReversedFrom..st diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st index d217b64..efcbaf1 100644 --- a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testComing.st @@ -1,6 +1,5 @@ tests testComing - | strm strm2 nextComing nextThree | strm := self newStreamNamed: 'testComing'. strm2 := self newStreamNamed: 'testComing'. diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsFrom.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsFrom.st new file mode 100644 index 0000000..541c106 --- /dev/null +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsFrom.st @@ -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 \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsReversedFrom.st b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsReversedFrom.st new file mode 100644 index 0000000..4ab42f4 --- /dev/null +++ b/repository/RediStick-Stream-Objects-Tests.package/RsRedisStreamTest.class/instance/testContentsReversedFrom.st @@ -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 \ No newline at end of file diff --git a/repository/RediStick-Stream-Objects.package/RsStream.class/instance/contentsReversedFrom..st b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/contentsReversedFrom..st new file mode 100644 index 0000000..ac921cf --- /dev/null +++ b/repository/RediStick-Stream-Objects.package/RsStream.class/instance/contentsReversedFrom..st @@ -0,0 +1,3 @@ +reading +contentsReversedFrom: fromMessageId + ^ self contentsReversedFrom: fromMessageId to: RsStreamMessageId min \ No newline at end of file