From c92ffde0442593de7c85663df7fcd3819d249a5b Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Sun, 8 Sep 2024 09:17:29 -0600 Subject: [PATCH] Added Cursor.At test --- cursor/cursor_test.go | 12 +++++++++++- go.mod | 4 +--- go.sum | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cursor/cursor_test.go b/cursor/cursor_test.go index 1602b67..9b10b96 100644 --- a/cursor/cursor_test.go +++ b/cursor/cursor_test.go @@ -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) { diff --git a/go.mod b/go.mod index 7755b1d..ba08155 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,8 @@ module git.codemonkeysoftware.net/b/gigaparsec go 1.23 require ( - github.com/shoenig/test v1.9.1 + github.com/shoenig/test v1.10.0 pgregory.net/rapid v1.1.0 ) require github.com/google/go-cmp v0.6.0 // indirect - -replace github.com/shoenig/test v1.9.1 => ../shoenig-test diff --git a/go.sum b/go.sum index 93587e3..ec772f0 100644 --- a/go.sum +++ b/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/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/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=