MCPcopy
hub / github.com/buger/jsonparser / TestGetDeepNesting

Function TestGetDeepNesting

obligation_property_test.go:558–586  ·  view source on GitHub ↗

============================================================================= Edge case tests ============================================================================= Verifies: SYS-REQ-089 MCDC SYS-REQ-089: get_input_is_deeply_nested=T, get_handles_deep_nesting_safely=T => TRUE

(t *testing.T)

Source from the content-addressed store, hash-verified

556// Verifies: SYS-REQ-089
557// MCDC SYS-REQ-089: get_input_is_deeply_nested=T, get_handles_deep_nesting_safely=T => TRUE
558func TestGetDeepNesting(t *testing.T) {
559 defer func() {
560 if r := recover(); r != nil {
561 t.Fatalf("Get on deeply nested JSON panicked: %v", r)
562 }
563 }()
564
565 // Build 64-level nested JSON: {"a":{"a":{"a":...42...}}}
566 depth := 64
567 var keys []string
568 prefix := strings.Repeat(`{"a":`, depth)
569 suffix := strings.Repeat(`}`, depth)
570 data := []byte(prefix + `42` + suffix)
571 for i := 0; i < depth; i++ {
572 keys = append(keys, "a")
573 }
574
575 val, dt, _, err := Get(data, keys...)
576 if err != nil {
577 t.Logf("Get on %d-deep nesting returned error (acceptable): %v", depth, err)
578 return
579 }
580 if dt != Number {
581 t.Fatalf("Expected Number type at depth %d, got %v", depth, dt)
582 }
583 if string(val) != "42" {
584 t.Fatalf("Expected value 42, got %q", val)
585 }
586}
587
588// Verifies: SYS-REQ-093
589// MCDC SYS-REQ-093: getstring_input_has_unicode_edge_cases=T, getstring_handles_unicode_edges_safely=T => TRUE

Callers

nothing calls this directly

Calls 1

GetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…