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

Function TestTraversalDeepNesting

obligation_property_test.go:716–756  ·  view source on GitHub ↗

Verifies: SYS-REQ-099 MCDC SYS-REQ-099: traversal_input_is_deeply_nested=T, traversal_handles_deep_nesting_safely=T => TRUE

(t *testing.T)

Source from the content-addressed store, hash-verified

714// Verifies: SYS-REQ-099
715// MCDC SYS-REQ-099: traversal_input_is_deeply_nested=T, traversal_handles_deep_nesting_safely=T => TRUE
716func TestTraversalDeepNesting(t *testing.T) {
717 t.Run("ArrayEach_deep", func(t *testing.T) {
718 defer func() {
719 if r := recover(); r != nil {
720 t.Fatalf("ArrayEach on deep nesting panicked: %v", r)
721 }
722 }()
723
724 // Build deeply nested array: [[[[...42...]]]]
725 depth := 64
726 prefix := strings.Repeat("[", depth)
727 suffix := strings.Repeat("]", depth)
728 data := []byte(prefix + "42" + suffix)
729
730 // ArrayEach on the outer array
731 _, err := ArrayEach(data, func(value []byte, dataType ValueType, offset int, err error) {
732 // The inner element is another deeply nested array or the final value
733 })
734 // We accept any result as long as no panic
735 _ = err
736 })
737
738 t.Run("ObjectEach_deep", func(t *testing.T) {
739 defer func() {
740 if r := recover(); r != nil {
741 t.Fatalf("ObjectEach on deep nesting panicked: %v", r)
742 }
743 }()
744
745 // Build deeply nested object: {"a":{"a":{"a":...{"a":42}...}}}
746 depth := 64
747 prefix := strings.Repeat(`{"a":`, depth)
748 suffix := strings.Repeat("}", depth)
749 data := []byte(prefix + "42" + suffix)
750
751 err := ObjectEach(data, func(key []byte, value []byte, dataType ValueType, offset int) error {
752 return nil
753 })
754 _ = err
755 })
756}
757
758// Verifies: SYS-REQ-102
759// MCDC SYS-REQ-102: mutation_input_has_unicode_keys=T, mutation_handles_unicode_keys_safely=T => TRUE

Callers

nothing calls this directly

Calls 2

ArrayEachFunction · 0.85
ObjectEachFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…