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

Function TestEachArrayAlias

aliases_test.go:40–68  ·  view source on GitHub ↗

Verifies: SYS-REQ-006 (array iteration alias) reqproof:proptest:skip parity test for a thin compatibility wrapper

(t *testing.T)

Source from the content-addressed store, hash-verified

38// Verifies: SYS-REQ-006 (array iteration alias)
39// reqproof:proptest:skip parity test for a thin compatibility wrapper
40func TestEachArrayAlias(t *testing.T) {
41 data := []byte(`{"payload":{"items":[1,"two",true,null]}}`)
42 var original, alias []arrayAliasObservation
43
44 _, originalErr := ArrayEach(data, func(value []byte, dataType ValueType, offset int, err error) {
45 original = append(original, arrayAliasObservation{
46 value: string(value),
47 dataType: dataType,
48 offset: offset,
49 err: aliasErrorString(err),
50 })
51 }, "payload", "items")
52 if originalErr != nil {
53 t.Fatalf("ArrayEach() error = %v, want nil", originalErr)
54 }
55
56 EachArray(data, func(value []byte, dataType ValueType, offset int, err error) {
57 alias = append(alias, arrayAliasObservation{
58 value: string(value),
59 dataType: dataType,
60 offset: offset,
61 err: aliasErrorString(err),
62 })
63 }, "payload", "items")
64
65 if !reflect.DeepEqual(alias, original) {
66 t.Fatalf("EachArray() observations = %#v, ArrayEach() observations = %#v", alias, original)
67 }
68}
69
70// Verifies: SYS-REQ-007 (object iteration alias)
71// reqproof:proptest:skip parity test for a thin compatibility wrapper

Callers

nothing calls this directly

Calls 3

ArrayEachFunction · 0.85
aliasErrorStringFunction · 0.85
EachArrayFunction · 0.85

Tested by

no test coverage detected