Compare commits

..

No commits in common. "776b513c444033ed77016fe0e6db332c72ec8079" and "82ade622745623ef24c0ab2e4323befa591be915" have entirely different histories.

2 changed files with 6 additions and 6 deletions

View File

@ -127,8 +127,8 @@ type State[In any] struct {
func (s State[In]) Read(dst []In) (n uint64, next State[In], err error) {
nread, err := s.r.ReadAt(dst, int64(s.pos))
if nread > 0 {
s.pos += uint64(nread)
if n > 0 {
s.pos += uint64(n)
}
return uint64(nread), s, err
}

View File

@ -48,8 +48,8 @@ func TestSlice(t *testing.T) {
}))
t.Run("fails at end of input", rapid.MakeCheck(func(t *rapid.T) {
s := rapid.SliceOfN(rapid.Byte(), 1, -1).Draw(t, "s")
input := rapid.Map(rapid.IntRange(0, len(s)-1),
func(n int) []byte { return s[:n] }).Draw(t, "inputLen")
inputLen := rapid.IntRange(0, len(s)-1).Draw(t, "inputLen")
input := s[:inputLen]
assertParseFails(t, input, gigaparsec.MatchSlice(s))
}))
t.Run("fails when read fails", rapid.MakeCheck(func(t *rapid.T) {
@ -63,8 +63,8 @@ func TestSlice(t *testing.T) {
}))
t.Run("succeeds when contents match", rapid.MakeCheck(func(t *rapid.T) {
input := rapid.SliceOfN(rapid.Byte(), 1, -1).Draw(t, "input")
s := rapid.Map(rapid.IntRange(0, len(input)),
func(n int) []byte { return input[:n] }).Draw(t, "s")
sLen := rapid.IntRange(0, len(input)).Draw(t, "sLen")
s := input[:sLen]
start := gigaparsec.MakeState(bytes.NewReader(input))
result, err := gigaparsec.MatchSlice(s)(start)