diff --git a/cursor/cursor_test.go b/cursor/cursor_test.go index 1b7bf33..3fa3e8e 100644 --- a/cursor/cursor_test.go +++ b/cursor/cursor_test.go @@ -55,7 +55,7 @@ func testCursor[C cursor.Cursor[byte]](t *testing.T, makeCursor func([]byte) C) t.Run("next cursor reads next input", rapid.MakeCheck(func(t *rapid.T) { const maxLen = 100 data := rapid.SliceOfN(rapid.Byte(), 1, maxLen).Draw(t, "data") - skip := rapid.IntRange(0, len(data)-1).Draw(t, "data") + skip := rapid.IntRange(0, len(data)-1).Draw(t, "skip") c := makeCursor(data) _, next, err := c.Read(make([]byte, skip)) @@ -84,7 +84,22 @@ func testCursor[C cursor.Cursor[byte]](t *testing.T, makeCursor func([]byte) C) test.NoError(t, err) test.EqOp(t, data[pos], dst[0]) })) - t.Run("Pos", Todo) + t.Run("Pos returns correct position after At", rapid.MakeCheck(func(t *rapid.T) { + var data []byte + pos := rapid.Uint64().Draw(t, "pos") + c := makeCursor(data).At(pos) + test.EqOp(t, pos, c.Pos()) + })) + t.Run("Pos returns correct position after Read", rapid.MakeCheck(func(t *rapid.T) { + const maxLen = 100 + data := rapid.SliceOfN(rapid.Byte(), 1, maxLen).Draw(t, "data") + skip := rapid.Uint64Range(0, uint64(len(data)-1)).Draw(t, "skip") + c := makeCursor(data) + + _, next, err := c.Read(make([]byte, skip)) + must.NoError(t, err) + test.EqOp(t, skip, next.Pos()) + })) } func TestSliceCursor(t *testing.T) {