Verifies: SYS-REQ-061 [malformed] A lone high surrogate is malformed per RFC 8259/WHATWG; per DEFECT-260727-SNGT the parser matches encoding/json by substituting U+FFFD (NOT returning MalformedValueError). SYS-REQ-061's strict error-return is superseded for the lone-surrogate case by the encoding/js
(t *testing.T)
| 620 | // MalformedValueError). SYS-REQ-061's strict error-return is superseded for |
| 621 | // the lone-surrogate case by the encoding/json parity fix. |
| 622 | func TestMissingSurrogateLow(t *testing.T) { |
| 623 | // \uD800 alone (high surrogate, no low) → U+FFFD substitution, no error. |
| 624 | got, err := ParseString([]byte(`\uD800`)) |
| 625 | if err != nil { |
| 626 | t.Fatalf("ParseString(high surrogate only) error = %v, want nil (U+FFFD substitution)", err) |
| 627 | } |
| 628 | if got != "\uFFFD" { |
| 629 | t.Fatalf("ParseString(high surrogate only) = %q, want %q (U+FFFD)", got, "\uFFFD") |
| 630 | } |
| 631 | |
| 632 | // High surrogate followed by non-escape text → U+FFFD + literal text. |
| 633 | got, err = ParseString([]byte(`\uD800abc`)) |
| 634 | if err != nil { |
| 635 | t.Fatalf("ParseString(high surrogate + text) error = %v, want nil", err) |
| 636 | } |
| 637 | if got != "\uFFFDabc" { |
| 638 | t.Fatalf("ParseString(high surrogate + text) = %q, want %q", got, "\uFFFDabc") |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | // Verifies: SYS-REQ-062 [malformed] |
| 643 | // A high surrogate followed by an out-of-range second escape is a lone high |
nothing calls this directly
no test coverage detected