Fixes after review

This commit is contained in:
alexej-v
2018-07-27 11:03:01 +03:00
parent 30bdb172b2
commit dd93bf1256
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -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 {
+3 -3
View File
@@ -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)
}
}
}