Fix bug where Result.Raw of literal 'false' was 'f'

This commit is contained in:
Erik Johnston 2017-11-20 17:55:52 +00:00
parent ac7b6ae6f2
commit 922b012d22
2 changed files with 10 additions and 1 deletions

View File

@ -511,7 +511,7 @@ func tonum(json string) (raw string, num float64) {
func tolit(json string) (raw string) { func tolit(json string) (raw string) {
for i := 1; i < len(json); i++ { for i := 1; i < len(json); i++ {
if json[i] <= 'a' || json[i] >= 'z' { if json[i] < 'a' || json[i] > 'z' {
return json[:i] return json[:i]
} }
} }

View File

@ -1101,3 +1101,12 @@ func TestGetMany48(t *testing.T) {
} }
} }
} }
func TestResultRawForLiteral(t *testing.T) {
for _, lit := range []string{"null", "true", "false"} {
result := Parse(lit)
if result.Raw != lit {
t.Fatalf("expected '%v', got '%v'", lit, result.Raw)
}
}
}