[🤖] Add Unit-Tests
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m34s

This commit is contained in:
2026-04-27 10:46:08 +02:00
parent dad0e3240d
commit 02d6894ec6
116 changed files with 18795 additions and 1 deletions
+61
View File
@@ -0,0 +1,61 @@
package cursortoken
import (
"git.blackforestbytes.com/BlackForestBytes/goext/tst"
"testing"
)
func TestPageToken(t *testing.T) {
tok := Page(5)
tst.AssertEqual(t, tok.Token(), "$5")
tst.AssertFalse(t, tok.IsEnd())
tst.AssertFalse(t, tok.IsStart())
}
func TestPageTokenOne(t *testing.T) {
tok := Page(1)
tst.AssertEqual(t, tok.Token(), "$1")
tst.AssertFalse(t, tok.IsEnd())
tst.AssertTrue(t, tok.IsStart())
}
func TestPageTokenLarge(t *testing.T) {
tok := Page(123456)
tst.AssertEqual(t, tok.Token(), "$123456")
}
func TestPageTokenZero(t *testing.T) {
tok := Page(0)
tst.AssertEqual(t, tok.Token(), "$0")
tst.AssertFalse(t, tok.IsEnd())
tst.AssertFalse(t, tok.IsStart())
}
func TestPageEndToken(t *testing.T) {
tok := PageEnd()
tst.AssertEqual(t, tok.Token(), "$end")
tst.AssertTrue(t, tok.IsEnd())
tst.AssertFalse(t, tok.IsStart())
}
func TestPaginatedStartMode(t *testing.T) {
tok := CTPaginated{Mode: CTMStart, Page: 0}
tst.AssertEqual(t, tok.Token(), "$1")
tst.AssertTrue(t, tok.IsStart())
tst.AssertFalse(t, tok.IsEnd())
}
func TestPaginatedEndMode(t *testing.T) {
tok := CTPaginated{Mode: CTMEnd, Page: 99}
tst.AssertEqual(t, tok.Token(), "$end")
tst.AssertTrue(t, tok.IsEnd())
}
func TestPaginatedRoundTrip(t *testing.T) {
for _, page := range []int{2, 3, 7, 100, 9999} {
tok := Page(page)
decoded, err := Decode(tok.Token())
tst.AssertNoErr(t, err)
tst.AssertEqual(t, decoded.Token(), tok.Token())
}
}