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

Function TestGetTruncatedReturnsError

deep_spec_test.go:975–992  ·  view source on GitHub ↗

Verifies: SYS-REQ-017 [malformed] Incomplete/truncated input returns parse error.

(t *testing.T)

Source from the content-addressed store, hash-verified

973// Verifies: SYS-REQ-017 [malformed]
974// Incomplete/truncated input returns parse error.
975func TestGetTruncatedReturnsError(t *testing.T) {
976 cases := []struct {
977 name string
978 data string
979 keys []string
980 }{
981 {name: "truncated value", data: `{"test":`, keys: []string{"test"}},
982 {name: "truncated string", data: `{"a":"hello`, keys: []string{"a"}},
983 }
984 for _, tc := range cases {
985 t.Run(tc.name, func(t *testing.T) {
986 _, _, _, err := Get([]byte(tc.data), tc.keys...)
987 if err == nil {
988 t.Fatalf("Get(%q, %v) should return error for truncated input", tc.data, tc.keys)
989 }
990 })
991 }
992}
993
994// Verifies: SYS-REQ-018 [boundary]
995// No key path returns root value.

Callers

nothing calls this directly

Calls 1

GetFunction · 0.85

Tested by

no test coverage detected