MCPcopy Index your code
hub / github.com/buger/jsonparser / TestTruncatedEscapeSequences

Function TestTruncatedEscapeSequences

deep_spec_test.go:598–615  ·  view source on GitHub ↗

Verifies: SYS-REQ-060 [malformed] Truncated escape sequences in ParseString shall return MalformedValueError.

(t *testing.T)

Source from the content-addressed store, hash-verified

596// Verifies: SYS-REQ-060 [malformed]
597// Truncated escape sequences in ParseString shall return MalformedValueError.
598func TestTruncatedEscapeSequences(t *testing.T) {
599 cases := []struct {
600 name string
601 input string
602 }{
603 {name: "truncated unicode 2 hex", input: `\u00`},
604 {name: "truncated unicode 1 hex", input: `\u0`},
605 {name: "truncated unicode no hex", input: `\u`},
606 }
607 for _, tc := range cases {
608 t.Run(tc.name, func(t *testing.T) {
609 _, err := ParseString([]byte(tc.input))
610 if !errors.Is(err, MalformedValueError) {
611 t.Fatalf("ParseString(%q) error = %v, want %v", tc.input, err, MalformedValueError)
612 }
613 })
614 }
615}
616
617// Verifies: SYS-REQ-061 [malformed]
618// High surrogate without low surrogate shall return MalformedValueError.

Callers

nothing calls this directly

Calls 1

ParseStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…