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

Function TestEachKeySentinelHandling

deep_spec_test.go:907–948  ·  view source on GitHub ↗

============================================================================= EachKey sentinel handling (SYS-REQ-085) ============================================================================= Verifies: SYS-REQ-085 [malformed] EachKey on truncated input with tokenEnd sentinel shall handle safely.

(t *testing.T)

Source from the content-addressed store, hash-verified

905// Verifies: SYS-REQ-085 [malformed]
906// EachKey on truncated input with tokenEnd sentinel shall handle safely.
907func TestEachKeySentinelHandling(t *testing.T) {
908 cases := []struct {
909 name string
910 data string
911 paths [][]string
912 }{
913 {
914 name: "truncated at value boundary",
915 data: `{"a":1`,
916 paths: [][]string{{"a"}},
917 },
918 {
919 name: "truncated mid key",
920 data: `{"a`,
921 paths: [][]string{{"a"}},
922 },
923 {
924 name: "truncated array",
925 data: `[1,2`,
926 paths: [][]string{{"[0]"}},
927 },
928 {
929 name: "missing value after colon",
930 data: `{"a":`,
931 paths: [][]string{{"a"}},
932 },
933 }
934 for _, tc := range cases {
935 t.Run(tc.name, func(t *testing.T) {
936 func() {
937 defer func() {
938 if r := recover(); r != nil {
939 t.Fatalf("EachKey(%q, %v) panicked: %v", tc.data, tc.paths, r)
940 }
941 }()
942 got := EachKey([]byte(tc.data), func(idx int, value []byte, vt ValueType, err error) {
943 }, tc.paths...)
944 _ = got
945 }()
946 })
947 }
948}
949
950// =============================================================================
951// Additional Get path tests for SYS-REQ-016 through SYS-REQ-027

Callers

nothing calls this directly

Calls 1

EachKeyFunction · 0.85

Tested by

no test coverage detected