byteflipAtStructuralByte flips a byte at a structural position ({, }, [, ], :, ,, "). This corrupts the document skeleton, exercising the parser's malformed-structure detection paths.
(r *rand.Rand, data []byte)
| 762 | // ], :, ,, "). This corrupts the document skeleton, exercising the parser's |
| 763 | // malformed-structure detection paths. |
| 764 | func byteflipAtStructuralByte(r *rand.Rand, data []byte) []byte { |
| 765 | pos := findStructuralBytes(data, '{', '}', '[', ']', ':', ',', '"') |
| 766 | if len(pos) == 0 { |
| 767 | return data |
| 768 | } |
| 769 | idx := pos[r.Intn(len(pos))] |
| 770 | out := make([]byte, len(data)) |
| 771 | copy(out, data) |
| 772 | // XOR with a nonzero mask to guarantee the byte changes. |
| 773 | out[idx] ^= byte(1 + r.Intn(255)) |
| 774 | return out |
| 775 | } |
| 776 | |
| 777 | // stringInsertionPoints returns the byte positions of all unescaped closing |
| 778 | // '"' chars that terminate a string body in data. Used by mutation operators |
nothing calls this directly
no test coverage detected