mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Fixed errors doubling
This commit is contained in:
@@ -652,8 +652,6 @@ func (r *Lexer) number() string {
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenNumber {
|
||||
if *UseSemanticErrors {
|
||||
r.errSemantic()
|
||||
r.SkipRecursive()
|
||||
return ""
|
||||
}
|
||||
r.errInvalidToken("number")
|
||||
|
||||
@@ -209,6 +209,9 @@ func TestNestedEasyJsonMarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSemanticErrors(t *testing.T) {
|
||||
if !*jlexer.UseSemanticErrors {
|
||||
return
|
||||
}
|
||||
for i, test := range []struct {
|
||||
Data []byte
|
||||
ErrorNum int
|
||||
@@ -217,6 +220,18 @@ func TestSemanticErrors(t *testing.T) {
|
||||
Data: []byte(`[1, 2, 3, "4", "5"]`),
|
||||
ErrorNum: 2,
|
||||
},
|
||||
{
|
||||
Data: []byte(`[1, {"2" : "3"}, 3, "4"`),
|
||||
ErrorNum: 2,
|
||||
},
|
||||
{
|
||||
Data: []byte(`[1, "2", "3", "4", "5", "6"]`),
|
||||
ErrorNum: 5,
|
||||
},
|
||||
{
|
||||
Data: []byte(`[1, 2, 3, 4, "5"]`),
|
||||
ErrorNum: 1,
|
||||
},
|
||||
} {
|
||||
l := jlexer.Lexer{Data: test.Data}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user