Skip to content

Commit

Permalink
test: improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jan 25, 2022
1 parent 4111b1c commit 4c906c3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
10 changes: 10 additions & 0 deletions dec_arr_iter_test.go
Expand Up @@ -33,4 +33,14 @@ func TestDecoder_ArrIter(t *testing.T) {
d := DecodeStr(s)
checker(t, testIter(d), s)
}
t.Run("Depth", func(t *testing.T) {
d := DecodeStr(`[`)
// Emulate depth
d.depth = maxDepth
require.ErrorIs(t, testIter(d), errMaxDepth)
})
t.Run("Empty", func(t *testing.T) {
d := DecodeStr(``)
require.ErrorIs(t, testIter(d), io.ErrUnexpectedEOF)
})
}
39 changes: 23 additions & 16 deletions dec_skip_cases_test.go
Expand Up @@ -208,22 +208,29 @@ var testObjs = []string{
}

var testArrs = []string{
`[]`, // valid
`[1]`, // valid
`[ 1, "hello"]`, // valid
`[abc]`, // invalid
`[`, // invalid
`[,`, // invalid
`[[]`, // invalid
"[true,f", // invalid
"[true", // invalid
"[true,", // invalid
"[true]", // invalid
"[true,]", // invalid
"[true,false", // invalid
"[true,false,", // invalid
"[true,false,]", // invalid
"[true,false}", // invalid
`[]`, // valid
`[ ]`, // valid
"[1]", // valid
"[true]", // valid
"[null]", // valid
`[ 1]`, // valid
`[ true]`, // valid
`[ null]`, // valid
`[ "abc" ` + "\n]", // valid
`[ "abc",` + "\n" + `"text"]`, // valid
`[ 1, "hello"]`, // valid
`[abc]`, // invalid
`[`, // invalid
`[,`, // invalid
`[[]`, // invalid
"[true,f", // invalid
"[true", // invalid
"[true,", // invalid
"[true,]", // invalid
"[true,false", // invalid
"[true,false,", // invalid
"[true,false,]", // invalid
"[true,false}", // invalid
}

func TestDecoder_Skip(t *testing.T) {
Expand Down

0 comments on commit 4c906c3

Please sign in to comment.