MCPcopy
hub / github.com/buger/jsonparser / TestCodeMCDC_DeleteArrayFirstElement

Function TestCodeMCDC_DeleteArrayFirstElement

mcdc_supplement_test.go:677–689  ·  view source on GitHub ↗

Verifies: SYS-REQ-035 [boundary] Code MC/DC gap: parser.go:800 Delete data[endOffset+tokEnd] == ']' Drive data[endOffset+tokEnd] == ']' to FALSE in the array-element deletion branch. This happens when deleting the first element of an array where the next delimiter is a comma, not ']'.

(t *testing.T)

Source from the content-addressed store, hash-verified

675// deletion branch. This happens when deleting the first element of an array
676// where the next delimiter is a comma, not ']'.
677func TestCodeMCDC_DeleteArrayFirstElement(t *testing.T) {
678 // Delete [0] from [1,2,3] -- the delimiter after "1" is ',' not ']'
679 got := string(Delete([]byte(`[1,2,3]`), "[0]"))
680 if got != `[2,3]` {
681 t.Fatalf("Delete array first element = %q, want %q", got, `[2,3]`)
682 }
683
684 // Delete [1] from [1,2,3] -- the delimiter after "2" is ',' not ']'
685 got2 := string(Delete([]byte(`[1,2,3]`), "[1]"))
686 if got2 != `[1,3]` {
687 t.Fatalf("Delete array middle element = %q, want %q", got2, `[1,3]`)
688 }
689}
690
691// Verifies: SYS-REQ-014 [boundary]
692// Code MC/DC gap: escape.go:149 Unescape for len(in) > 0

Callers

nothing calls this directly

Calls 1

DeleteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…