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

Function TestPropertyObjectEachCompleteness

property_test.go:365–384  ·  view source on GitHub ↗

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

(t *testing.T)

Source from the content-addressed store, hash-verified

363// reqproof:proptest ObjectEach
364// Verifies: SYS-REQ-007 [property]
365func TestPropertyObjectEachCompleteness(t *testing.T) {
366 r := newRNG(jsonSeed + 3)
367 const iterations = 1000
368 for i := 0; i < iterations; i++ {
369 raw, obj := randomObjectJSONBytes(r, 1)
370 seen := map[string]bool{}
371 oerr := ObjectEach(raw, func(key, value []byte, dataType ValueType, offset int) error {
372 seen[string(key)] = true
373 return nil
374 })
375 if oerr != nil {
376 t.Fatalf("ObjectEach errored on valid object %q: %v", raw, oerr)
377 }
378 for k := range obj {
379 if !seen[k] {
380 t.Fatalf("ObjectEach missed key %q on input %q (seen=%v)", k, raw, seen)
381 }
382 }
383 }
384}
385
386// ---------------------------------------------------------------------------
387// 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