Test all byte reading functions with fuzzing inputs. Since we are reading bytes memory allocations should be well controlled.
(f *testing.F)
| 142 | // Test all byte reading functions with fuzzing inputs. |
| 143 | // Since we are reading bytes memory allocations should be well controlled. |
| 144 | func FuzzReadBytes(f *testing.F) { |
| 145 | addFuzzDataFromZip(f, "testdata/FuzzCorpus.zip") |
| 146 | |
| 147 | f.Fuzz(func(t *testing.T, data []byte) { |
| 148 | if len(data) == 0 || len(data) > 1<<20 { |
| 149 | return |
| 150 | } |
| 151 | var tmp5 [5]byte |
| 152 | |
| 153 | ReadArrayHeaderBytes(data) |
| 154 | ReadBoolBytes(data) |
| 155 | ReadByteBytes(data) |
| 156 | ReadBytesBytes(data, tmp5[:]) |
| 157 | ReadBytesZC(data) |
| 158 | ReadComplex128Bytes(data) |
| 159 | ReadComplex64Bytes(data) |
| 160 | ReadDurationBytes(data) |
| 161 | ReadExactBytes(data, tmp5[:]) |
| 162 | ReadExtensionBytes(data, testExt{}) |
| 163 | ReadFloat32Bytes(data) |
| 164 | ReadFloat64Bytes(data) |
| 165 | ReadInt8Bytes(data) |
| 166 | ReadInt16Bytes(data) |
| 167 | ReadInt32Bytes(data) |
| 168 | ReadInt64Bytes(data) |
| 169 | ReadIntBytes(data) |
| 170 | ReadIntfBytes(data) |
| 171 | ReadJSONNumberBytes(data) |
| 172 | ReadMapHeaderBytes(data) |
| 173 | ReadMapKeyZC(data) |
| 174 | ReadMapStrIntfBytes(data, map[string]any{}) |
| 175 | ReadNilBytes(data) |
| 176 | ReadStringBytes(data) |
| 177 | ReadStringAsBytes(data, tmp5[:]) |
| 178 | ReadStringBytes(data) |
| 179 | ReadStringZC(data) |
| 180 | ReadTimeBytes(data) |
| 181 | ReadTimeUTCBytes(data) |
| 182 | ReadUint8Bytes(data) |
| 183 | ReadUint16Bytes(data) |
| 184 | ReadUint32Bytes(data) |
| 185 | ReadUint64Bytes(data) |
| 186 | ReadUintBytes(data) |
| 187 | UnmarshalAsJSON(io.Discard, data) |
| 188 | iter, errfn := ReadArrayBytes(data, ReadIntBytes) |
| 189 | for range iter { |
| 190 | } |
| 191 | errfn() |
| 192 | iter2, errfn2 := ReadMapBytes(data, ReadStringBytes, ReadUint64Bytes) |
| 193 | for range iter2 { |
| 194 | } |
| 195 | errfn2() |
| 196 | Skip(data) |
| 197 | }) |
| 198 | } |
| 199 | |
| 200 | type testExt struct{} |
| 201 |
nothing calls this directly
no test coverage detected
searching dependent graphs…