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

Function TestPropertyObjectEachCompleteness

property_test.go:380–399  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Property: ObjectEach visits every key-value pair exactly once --------------------------------------------------------------------------- reqproof:proptest parser.ObjectEach Verifies: SYS-REQ-007 [property]

(t *testing.T)

Source from the content-addressed store, hash-verified

378// reqproof:proptest parser.ObjectEach
379// Verifies: SYS-REQ-007 [property]
380func TestPropertyObjectEachCompleteness(t *testing.T) {
381 r := newRNG(jsonSeed + 3)
382 const iterations = 1000
383 for i := 0; i < iterations; i++ {
384 raw, obj := randomObjectJSONBytes(r, 1)
385 seen := map[string]bool{}
386 oerr := ObjectEach(raw, func(key, value []byte, dataType ValueType, offset int) error {
387 seen[string(key)] = true
388 return nil
389 })
390 if oerr != nil {
391 t.Fatalf("ObjectEach errored on valid object %q: %v", raw, oerr)
392 }
393 for k := range obj {
394 if !seen[k] {
395 t.Fatalf("ObjectEach missed key %q on input %q (seen=%v)", k, raw, seen)
396 }
397 }
398 }
399}
400
401// ---------------------------------------------------------------------------
402// Property: EachKey dispatches to matching paths without panic

Callers

nothing calls this directly

Calls 3

newRNGFunction · 0.85
randomObjectJSONBytesFunction · 0.85
ObjectEachFunction · 0.85

Tested by

no test coverage detected