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

Function TestCodeMCDC_UnescapeLoopEntry

mcdc_supplement_test.go:698–716  ·  view source on GitHub ↗

Verifies: SYS-REQ-014 [boundary] Code MC/DC gap: escape.go:149 Unescape for len(in) > 0 Drive the loop body. A string with an escape sequence enters the loop.

(t *testing.T)

Source from the content-addressed store, hash-verified

696// Code MC/DC gap: escape.go:149 Unescape for len(in) > 0
697// Drive the loop body. A string with an escape sequence enters the loop.
698func TestCodeMCDC_UnescapeLoopEntry(t *testing.T) {
699 // A string with a backslash-n escape forces the Unescape loop
700 result, err := Unescape([]byte(`hello\nworld`), make([]byte, 32))
701 if err != nil {
702 t.Fatalf("Unescape error: %v", err)
703 }
704 if string(result) != "hello\nworld" {
705 t.Fatalf("Unescape = %q, want %q", string(result), "hello\nworld")
706 }
707
708 // Also test with multiple escapes to exercise loop re-entry
709 result2, err2 := Unescape([]byte(`a\tb\nc`), make([]byte, 32))
710 if err2 != nil {
711 t.Fatalf("Unescape multiple escapes error: %v", err2)
712 }
713 if string(result2) != "a\tb\nc" {
714 t.Fatalf("Unescape multiple = %q, want %q", string(result2), "a\tb\nc")
715 }
716}
717
718// Verifies: SYS-REQ-007 [boundary]
719// Code MC/DC gap: parser.go:1138 ObjectEach offset < len(data)

Callers

nothing calls this directly

Calls 1

UnescapeFunction · 0.85

Tested by

no test coverage detected