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

Function TestRemoval2_Inconsistency_TruncatedNumber

dead_code_audit_test.go:183–195  ·  view source on GitHub ↗

Critical: tokenEnd returns len(data) vs stringEnd/blockEnd returning -1. The inconsistency means getType silently accepts truncated tokens. Verifies: SYS-REQ-001 [boundary]

(t *testing.T)

Source from the content-addressed store, hash-verified

181// The inconsistency means getType silently accepts truncated tokens.
182// Verifies: SYS-REQ-001 [boundary]
183func TestRemoval2_Inconsistency_TruncatedNumber(t *testing.T) {
184 // Consider: `{"a": 12` — the number "12" has no terminator.
185 // tokenEnd("12") returns 2, so getType will return "12" as a Number.
186 // This is actually CORRECT behavior for a streaming parser,
187 // but it means we can't distinguish "complete number" from "truncated input".
188 // The removed guard would NOT have caught this either (tokenEnd never returns -1).
189 val, dt, _, err := Get([]byte(`{"a": 12`), "a")
190 if err != nil {
191 t.Logf("Error on truncated number: %v (this is fine)", err)
192 } else {
193 t.Logf("Truncated number parsed as: val=%q type=%v", val, dt)
194 }
195}
196
197// =============================================================================
198// REMOVAL 3: `r <= basicMultilingualPlaneOffset` removed in decodeUnicodeEscape

Callers

nothing calls this directly

Calls 1

GetFunction · 0.85

Tested by

no test coverage detected