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

Function runNoPanic

empty_key_path_test.go:23–31  ·  view source on GitHub ↗

Regression coverage for the empty-string key path component hazard (hazard-sweep finding). A caller passing "" as a path component used to trigger `runtime error: index out of range [0] with length 0` at the unguarded `keys[i][0]` / `p[level][0]` dereference sites in searchKeys, EachKey, createInser

(t *testing.T, name string, fn func())

Source from the content-addressed store, hash-verified

21// runNoPanic executes fn and fails the test if it panics, returning the
22// recovered value so callers can also assert on the post-fix result.
23func runNoPanic(t *testing.T, name string, fn func()) {
24 t.Helper()
25 defer func() {
26 if r := recover(); r != nil {
27 t.Fatalf("%s panicked (empty-key regression): %v", name, r)
28 }
29 }()
30 fn()
31}
32
33// =============================================================================
34// Get family — empty key component resolves to KeyPathNotFoundError (SYS-REQ-016)

Calls

no outgoing calls

Tested by

no test coverage detected