Improve MatchSlice test output
This commit is contained in:
parent
82ade62274
commit
e6debbd7dc
@ -48,8 +48,8 @@ func TestSlice(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
t.Run("fails at end of input", rapid.MakeCheck(func(t *rapid.T) {
|
t.Run("fails at end of input", rapid.MakeCheck(func(t *rapid.T) {
|
||||||
s := rapid.SliceOfN(rapid.Byte(), 1, -1).Draw(t, "s")
|
s := rapid.SliceOfN(rapid.Byte(), 1, -1).Draw(t, "s")
|
||||||
inputLen := rapid.IntRange(0, len(s)-1).Draw(t, "inputLen")
|
input := rapid.Map(rapid.IntRange(0, len(s)-1),
|
||||||
input := s[:inputLen]
|
func(n int) []byte { return s[:n] }).Draw(t, "inputLen")
|
||||||
assertParseFails(t, input, gigaparsec.MatchSlice(s))
|
assertParseFails(t, input, gigaparsec.MatchSlice(s))
|
||||||
}))
|
}))
|
||||||
t.Run("fails when read fails", rapid.MakeCheck(func(t *rapid.T) {
|
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) {
|
t.Run("succeeds when contents match", rapid.MakeCheck(func(t *rapid.T) {
|
||||||
input := rapid.SliceOfN(rapid.Byte(), 1, -1).Draw(t, "input")
|
input := rapid.SliceOfN(rapid.Byte(), 1, -1).Draw(t, "input")
|
||||||
sLen := rapid.IntRange(0, len(input)).Draw(t, "sLen")
|
s := rapid.Map(rapid.IntRange(0, len(input)),
|
||||||
s := input[:sLen]
|
func(n int) []byte { return input[:n] }).Draw(t, "s")
|
||||||
start := gigaparsec.MakeState(bytes.NewReader(input))
|
start := gigaparsec.MakeState(bytes.NewReader(input))
|
||||||
|
|
||||||
result, err := gigaparsec.MatchSlice(s)(start)
|
result, err := gigaparsec.MatchSlice(s)(start)
|
||||||
|
Loading…
Reference in New Issue
Block a user