diff --git a/jlexer/lexer.go b/jlexer/lexer.go index 24cec21..51f0566 100644 --- a/jlexer/lexer.go +++ b/jlexer/lexer.go @@ -345,7 +345,7 @@ func (r *Lexer) fetchString() { isValid, hasEscapes, length := findStringLen(data) if !isValid { r.pos += length - r.errParse("missing trailing string literal") + r.errParse("unterminated string literal") return } if !hasEscapes { diff --git a/jlexer/lexer_test.go b/jlexer/lexer_test.go index 2a655dd..3149ce4 100644 --- a/jlexer/lexer_test.go +++ b/jlexer/lexer_test.go @@ -317,17 +317,17 @@ func TestFetchStringUnterminatedString(t *testing.T) { for _, test := range []struct { data []byte }{ - {data: []byte(`"sting without trailing literal`)}, + {data: []byte(`"sting without trailing quote`)}, {data: []byte(`"\"`)}, {data: []byte{'"'}}, } { l := Lexer{Data: test.data} l.fetchString() if l.pos > len(l.Data) { - t.Errorf("pos should not be greater than length of Data") + t.Errorf("fetchString(%s): pos should not be greater than length of Data", test.data) } if l.Error() == nil { - t.Errorf("fetchString() should add parsing error") + t.Errorf("fetchString(%s): should add parsing error", test.data) } } }