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

Function TestGetObjectLenRoundTrip

len_uint_test.go:279–298  ·  view source on GitHub ↗

Verifies: SYS-REQ-112 (container length accessor). reqproof:proptest:skip targeted witness/regression test; not a property-test subject

(t *testing.T)

Source from the content-addressed store, hash-verified

277// Verifies: SYS-REQ-112 (container length accessor).
278// reqproof:proptest:skip targeted witness/regression test; not a property-test subject
279func TestGetObjectLenRoundTrip(t *testing.T) {
280 data := []byte(`{"value":{"one":1,"two":"a,b","three":{"nested":true},"four":[1,2]}}`)
281
282 got, err := GetObjectLen(data, "value")
283 if err != nil {
284 t.Fatalf("GetObjectLen() unexpected error: %v", err)
285 }
286
287 callbacks := 0
288 err = ObjectEach(data, func(_ []byte, _ []byte, _ ValueType, _ int) error {
289 callbacks++
290 return nil
291 }, "value")
292 if err != nil {
293 t.Fatalf("ObjectEach() unexpected error: %v", err)
294 }
295 if got != callbacks {
296 t.Fatalf("GetObjectLen() = %d, ObjectEach callbacks = %d", got, callbacks)
297 }
298}

Callers

nothing calls this directly

Calls 2

GetObjectLenFunction · 0.85
ObjectEachFunction · 0.85

Tested by

no test coverage detected