Test ReaderAtCursor with failing ReaderAt

This commit is contained in:
2024-09-13 11:17:32 -06:00
parent 4761259567
commit c9ee9916eb
3 changed files with 26 additions and 2 deletions

View File

@ -2,12 +2,12 @@ package gigaparsec_test
import (
"bytes"
"errors"
"testing"
"git.codemonkeysoftware.net/b/gigaparsec"
"git.codemonkeysoftware.net/b/gigaparsec/cursor"
ptest "git.codemonkeysoftware.net/b/gigaparsec/test"
"git.codemonkeysoftware.net/b/gigaparsec/test/generator"
"github.com/shoenig/test"
"github.com/shoenig/test/must"
"pgregory.net/rapid"
@ -52,7 +52,7 @@ func TestSlice(t *testing.T) {
assertParseFails(t, input, gigaparsec.Slice(s))
}))
t.Run("fails when read fails", rapid.MakeCheck(func(t *rapid.T) {
expectedErr := rapid.Map(rapid.StringN(0, 100, -1), errors.New).Draw(t, "err")
expectedErr := generator.Error().Draw(t, "expectedErr")
c := ptest.ErrCursor[byte](expectedErr)
s := rapid.SliceOfN(rapid.Byte(), 0, 100).Draw(t, "s")
result, err := gigaparsec.Slice(s)(gigaparsec.MakeState(c))