Added Cursor.At test
This commit is contained in:
parent
a2e9d2cc8d
commit
c92ffde044
@ -73,7 +73,17 @@ func testCursor[C cursor.Cursor[byte]](t *testing.T, makeCursor func([]byte) C)
|
|||||||
test.ErrorIs(t, err, io.EOF)
|
test.ErrorIs(t, err, io.EOF)
|
||||||
test.EqOp(t, len(data), int(n))
|
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) {
|
func TestSliceCursor(t *testing.T) {
|
||||||
|
4
go.mod
4
go.mod
@ -3,10 +3,8 @@ module git.codemonkeysoftware.net/b/gigaparsec
|
|||||||
go 1.23
|
go 1.23
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/shoenig/test v1.9.1
|
github.com/shoenig/test v1.10.0
|
||||||
pgregory.net/rapid v1.1.0
|
pgregory.net/rapid v1.1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require github.com/google/go-cmp v0.6.0 // indirect
|
require github.com/google/go-cmp v0.6.0 // indirect
|
||||||
|
|
||||||
replace github.com/shoenig/test v1.9.1 => ../shoenig-test
|
|
||||||
|
2
go.sum
2
go.sum
@ -1,4 +1,6 @@
|
|||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/shoenig/test v1.10.0 h1:cf/OnhhbkMnJ0uk39OUwbY+x/OT5x20D69pdNACeBwc=
|
||||||
|
github.com/shoenig/test v1.10.0/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI=
|
||||||
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
|
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
|
||||||
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
|
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
|
||||||
|
Loading…
Reference in New Issue
Block a user