valyala / fastjson

Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection
MIT License
2.3k stars 138 forks source link

Add test for hasSpecialChars #100

Open elliotwutingfeng opened 1 year ago

elliotwutingfeng commented 1 year ago
func hasSpecialChars(s string) bool {
    if strings.IndexByte(s, '"') >= 0 || strings.IndexByte(s, '\\') >= 0 {
        return true
    }
    for i := 0; i < len(s); i++ {
        if s[i] < 0x20 {
            return true
        }
    }
    return false
}

This PR modifies testArena to cover if s[i] < 0x20 in hasSpecialChars; improves overall test coverage slightly.