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

Function TestParseInt_SignOnlyTripwire_KI2

parser_test.go:2457–2473  ·  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

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

Callers

nothing calls this directly

Calls 1

ParseIntFunction · 0.85

Tested by

no test coverage detected