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

Function TestGetArrayIndexInBounds

deep_spec_test.go:1036–1045  ·  view source on GitHub ↗

Verifies: SYS-REQ-021 [boundary] Valid in-bounds array index returns correct element.

(t *testing.T)

Source from the content-addressed store, hash-verified

1034// Verifies: SYS-REQ-021 [boundary]
1035// Valid in-bounds array index returns correct element.
1036func TestGetArrayIndexInBounds(t *testing.T) {
1037 data := []byte(`{"arr":[10,20,30]}`)
1038 val, _, _, err := Get(data, "arr", "[1]")
1039 if err != nil {
1040 t.Fatalf("Get array index error: %v", err)
1041 }
1042 if string(val) != "20" {
1043 t.Fatalf("Get array index = %q, want %q", string(val), "20")
1044 }
1045}
1046
1047// Verifies: SYS-REQ-022 [boundary]
1048// Malformed array index returns not-found.

Callers

nothing calls this directly

Calls 1

GetFunction · 0.85

Tested by

no test coverage detected