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

Function TestPropertyInternalGetConsistentWithGet

property_test.go:822–839  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Property: internalGet agrees with Get (Get is a thin projection) --------------------------------------------------------------------------- reqproof:proptest internalGet Verifies: SYS-REQ-001 [property]

(t *testing.T)

Source from the content-addressed store, hash-verified

820// reqproof:proptest internalGet
821// Verifies: SYS-REQ-001 [property]
822func TestPropertyInternalGetConsistentWithGet(t *testing.T) {
823 r := newRNG(jsonSeed + 12)
824 const iterations = 1000
825 for i := 0; i < iterations; i++ {
826 raw := randomJSONBytes(r, 2)
827 keys := []string{randKey(r)}
828 // Get is `a, b, _, d, e := internalGet(...); return a, b, d, e` — i.e.
829 // Get's offset is internalGet's END offset, not its start offset.
830 // So we compare value, type, and error; offsets are related but
831 // not identical fields.
832 v1, t1, _, e1 := Get(raw, keys...)
833 v2, t2, _, _, e2 := internalGet(raw, keys...)
834 if !bytes.Equal(v1, v2) || t1 != t2 || (e1 == nil) != (e2 == nil) {
835 t.Fatalf("internalGet/Get disagree on input %q keys=%v: Get=(%q,%v,err=%v) iGet=(%q,%v,err=%v)",
836 raw, keys, v1, t1, e1, v2, t2, e2)
837 }
838 }
839}
840
841// ---------------------------------------------------------------------------
842// Property: WriteToBuffer / calcAllocateSpace / createInsertComponent are pure

Callers

nothing calls this directly

Calls 5

newRNGFunction · 0.85
randomJSONBytesFunction · 0.85
randKeyFunction · 0.85
GetFunction · 0.85
internalGetFunction · 0.85

Tested by

no test coverage detected