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

Function TestInvalidSurrogateLow

deep_spec_test.go:646–655  ·  view source on GitHub ↗

Verifies: SYS-REQ-062 [malformed] A high surrogate followed by an out-of-range second escape is a lone high surrogate → U+FFFD + the second escape reprocessed, matching encoding/json (DEFECT-260727-SNGT). SYS-REQ-062's error-return is superseded for this case.

(t *testing.T)

Source from the content-addressed store, hash-verified

644// surrogate → U+FFFD + the second escape reprocessed, matching encoding/json
645// (DEFECT-260727-SNGT). SYS-REQ-062's error-return is superseded for this case.
646func TestInvalidSurrogateLow(t *testing.T) {
647 // \uD800\u0041 - valid unicode escape but not in low surrogate range → U+FFFD + 'A'.
648 got, err := ParseString([]byte(`\uD800\u0041`))
649 if err != nil {
650 t.Fatalf("ParseString(invalid low surrogate) error = %v, want nil (U+FFFD + 'A')", err)
651 }
652 if got != "\uFFFDA" {
653 t.Fatalf("ParseString(invalid low surrogate) = %q, want %q", got, "\uFFFDA")
654 }
655}
656
657// Verifies: SYS-REQ-063 [malformed]
658// Backslash at end of string shall return MalformedValueError.

Callers

nothing calls this directly

Calls 1

ParseStringFunction · 0.85

Tested by

no test coverage detected