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

Function TestGetArrayLenRoundTrip

len_uint_test.go:253–275  ·  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

251// Verifies: SYS-REQ-112 (container length accessor).
252// reqproof:proptest:skip targeted witness/regression test; not a property-test subject
253func TestGetArrayLenRoundTrip(t *testing.T) {
254 data := []byte(`{"values":[1,"two,three",{"four":[4,5]},[6,7],null]}`)
255
256 got, err := GetArrayLen(data, "values")
257 if err != nil {
258 t.Fatalf("GetArrayLen() unexpected error: %v", err)
259 }
260
261 callbacks := 0
262 _, err = ArrayEach(data, func(_ []byte, _ ValueType, _ int, callbackErr error) {
263 if callbackErr != nil {
264 t.Errorf("ArrayEach callback error: %v", callbackErr)
265 return
266 }
267 callbacks++
268 }, "values")
269 if err != nil {
270 t.Fatalf("ArrayEach() unexpected error: %v", err)
271 }
272 if got != callbacks {
273 t.Fatalf("GetArrayLen() = %d, ArrayEach callbacks = %d", got, callbacks)
274 }
275}
276
277// Verifies: SYS-REQ-112 (container length accessor).
278// reqproof:proptest:skip targeted witness/regression test; not a property-test subject

Callers

nothing calls this directly

Calls 2

GetArrayLenFunction · 0.85
ArrayEachFunction · 0.85

Tested by

no test coverage detected