MCPcopy Create free account
hub / github.com/buger/jsonparser / TestParseInt_SignOnlyTripwire_KI2

Function TestParseInt_SignOnlyTripwire_KI2

parser_test.go:2456–2472  ·  view source on GitHub ↗

TestParseInt_SignOnlyTripwire_KI2 reproduces the live failure mode tracked as KnownIssue KI-2 / DEFECT-260726-3F95. It PASSES while the bug is present (ParseInt("-") returns (0, nil)) and FAILS the moment the one-line guard lands in bytes.go:parseInt, at which point KI-2 must be flipped to status: f

(t *testing.T)

Source from the content-addressed store, hash-verified

2454//
2455// Reproduces: KI-2
2456func TestParseInt_SignOnlyTripwire_KI2(t *testing.T) {
2457 v, err := ParseInt([]byte("-"))
2458 // Tripwire: while the bug is present, the call returns (0, nil).
2459 if err != nil {
2460 t.Fatalf("KI-2 tripwire no longer reproduces: ParseInt(\"-\") err = %v (the bug has been FIXED — flip KI-2 to status: fixed and delete this tripwire)", err)
2461 }
2462 if v != 0 {
2463 t.Fatalf("KI-2 tripwire no longer reproduces: ParseInt(\"-\") v = %d (the bug has been FIXED — flip KI-2 to status: fixed and delete this tripwire)", v)
2464 }
2465 // Also exercise the `+`-prefixed variant for documentation: parseInt does
2466 // not treat `+` as a sign, so it hits the c < '0' branch and correctly
2467 // returns MalformedValueError. This row pins the asymmetry so a future
2468 // fix that accidentally widened the sign classifier surfaces here too.
2469 if _, err := ParseInt([]byte("+")); err == nil {
2470 t.Fatalf("ParseInt(\"+\") unexpectedly returned nil error — `+` is not a JSON number prefix")
2471 }
2472}
2473
2474// Reproduces: KI-4
2475// TestSetTopLevelArrayBeyondLength_KI4 documents the open design gap

Callers

nothing calls this directly

Calls 1

ParseIntFunction · 0.85

Tested by

no test coverage detected