Consume entire input in sexp parser
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"git.codemonkeysoftware.net/b/peachy-go/csexp"
|
||||
"git.codemonkeysoftware.net/b/peachy-go/csexp/gen"
|
||||
"github.com/shoenig/test"
|
||||
"github.com/shoenig/test/must"
|
||||
"pgregory.net/rapid"
|
||||
)
|
||||
@@ -33,6 +34,19 @@ func TestStringAndParseEqual(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseFails(t *testing.T) {
|
||||
t.Run("with extra input", rapid.MakeCheck(func(t *rapid.T) {
|
||||
sexp := gen.Sexp().Draw(t, "sexp")
|
||||
b := []byte(sexp.String())
|
||||
extra := rapid.SliceOfN(rapid.Byte(), 1, -1).Draw(t, "extra")
|
||||
b = append(b, extra...)
|
||||
parsed, err := csexp.Parse(b)
|
||||
test.Error(t, err)
|
||||
test.Nil(t, parsed)
|
||||
}))
|
||||
t.Run("with too little input", rapid.MakeCheck(func(t *rapid.T) {}))
|
||||
}
|
||||
|
||||
func TestCloneEqual(t *testing.T) {
|
||||
rapid.Check(t, func(t *rapid.T) {
|
||||
sexp := gen.Sexp().Draw(t, "sexp")
|
||||
|
||||
Reference in New Issue
Block a user