Added Cursor.At test

This commit is contained in:
2024-09-08 09:17:29 -06:00
parent a2e9d2cc8d
commit c92ffde044
3 changed files with 14 additions and 4 deletions

View File

@ -73,7 +73,17 @@ func testCursor[C cursor.Cursor[byte]](t *testing.T, makeCursor func([]byte) C)
test.ErrorIs(t, err, io.EOF)
test.EqOp(t, len(data), int(n))
}))
t.Run("At", Todo)
t.Run("At sets cursor position", rapid.MakeCheck(func(t *rapid.T) {
data := rapid.SliceOfN(rapid.Byte(), 1, 100).Draw(t, "data")
pos := rapid.Uint64Range(0, uint64(len(data)-1)).Draw(t, "pos")
c := makeCursor(data).At(pos)
dst := make([]byte, 1)
n, _, err := c.Read(dst)
test.EqOp(t, 1, n)
test.NoError(t, err)
test.EqOp(t, data[pos], dst[0])
}))
}
func TestSliceCursor(t *testing.T) {