============================================================================= Gate runner (the assertions that catch each bug class) ============================================================================= runStructureAwareGates exercises the full parser surface against the given data + path, a
(t *testing.T, data []byte, path []string)
| 1240 | // divergence (the latter are excluded from OUTPUT-VALIDITY via |
| 1241 | // pathShapeMatchesRoot, matching path_fuzz_test.go's convention). |
| 1242 | func runStructureAwareGates(t *testing.T, data []byte, path []string) { |
| 1243 | t.Helper() |
| 1244 | |
| 1245 | dataValid := json.Valid(data) |
| 1246 | |
| 1247 | // --- NO-PANIC gate + NUMERIC-ORACLE gate (Get family) --- |
| 1248 | |
| 1249 | runOpNoPanic(t, "Get", data, path, func() { |
| 1250 | val, dt, _, err := Get(data, path...) |
| 1251 | if err != nil || dt != Number || len(val) == 0 { |
| 1252 | return |
| 1253 | } |
| 1254 | // NUMERIC-ORACLE: only compare against strconv for valid JSON |
| 1255 | // documents. For invalid/truncated JSON, the parser may classify |
| 1256 | // garbage tokens (like "-") as Number, and strconv will legitimately |
| 1257 | // disagree on those — that's the parser's lenient tokenization, |
| 1258 | // not a numeric-parsing bug. |
| 1259 | if dataValid { |
| 1260 | checkNumericOracle(t, val) |
| 1261 | } |
| 1262 | }) |
| 1263 | runOpNoPanic(t, "GetString", data, path, func() { |
| 1264 | _, _ = GetString(data, path...) |
| 1265 | }) |
| 1266 | runOpNoPanic(t, "GetInt", data, path, func() { |
| 1267 | _, _ = GetInt(data, path...) |
| 1268 | }) |
| 1269 | runOpNoPanic(t, "GetFloat", data, path, func() { |
| 1270 | _, _ = GetFloat(data, path...) |
| 1271 | }) |
| 1272 | runOpNoPanic(t, "GetBoolean", data, path, func() { |
| 1273 | _, _ = GetBoolean(data, path...) |
| 1274 | }) |
| 1275 | runOpNoPanic(t, "GetUnsafeString", data, path, func() { |
| 1276 | _, _ = GetUnsafeString(data, path...) |
| 1277 | }) |
| 1278 | |
| 1279 | // --- NEW GATES (closes Dimension 1 & 4 blind spots) --- |
| 1280 | // These exercise properties the original gate set did NOT assert: |
| 1281 | // - OFFSET-BOUNDS: Get's offset return ∈ [-1, len(data)] |
| 1282 | // - DETERMINISM: two Get calls return byte-identical results (SYS-REQ-086) |
| 1283 | // - ALIASING: Get's value slice appears as a sub-slice of data |
| 1284 | // - PARSESTRING: grammar-generated escape sequences reach ParseString |
| 1285 | // - PARSEBOOLEAN: Boolean-typed values reach ParseBoolean cross-check |
| 1286 | runOpNoPanic(t, "Get/OffsetBounds", data, path, func() { |
| 1287 | checkOffsetBoundsGate(t, data, path) |
| 1288 | }) |
| 1289 | runOpNoPanic(t, "Get/Determinism", data, path, func() { |
| 1290 | checkDeterminismGate(t, data, path) |
| 1291 | }) |
| 1292 | runOpNoPanic(t, "Get/SliceAliasing", data, path, func() { |
| 1293 | checkSliceAliasingGate(t, data, path) |
| 1294 | }) |
| 1295 | runOpNoPanic(t, "Get/ParseString", data, path, func() { |
| 1296 | checkParseStringGate(t, data, path) |
| 1297 | }) |
| 1298 | runOpNoPanic(t, "Get/ParseBoolean", data, path, func() { |
| 1299 | checkParseBooleanGate(t, data, path) |
no test coverage detected