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

Function TestCodeMCDC_DeleteArrayFirstElement

mcdc_supplement_test.go:681–693  ·  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

679// deletion branch. This happens when deleting the first element of an array
680// where the next delimiter is a comma, not ']'.
681func TestCodeMCDC_DeleteArrayFirstElement(t *testing.T) {
682 // Delete [0] from [1,2,3] -- the delimiter after "1" is ',' not ']'
683 got := string(Delete([]byte(`[1,2,3]`), "[0]"))
684 if got != `[2,3]` {
685 t.Fatalf("Delete array first element = %q, want %q", got, `[2,3]`)
686 }
687
688 // Delete [1] from [1,2,3] -- the delimiter after "2" is ',' not ']'
689 got2 := string(Delete([]byte(`[1,2,3]`), "[1]"))
690 if got2 != `[1,3]` {
691 t.Fatalf("Delete array middle element = %q, want %q", got2, `[1,3]`)
692 }
693}
694
695// Verifies: SYS-REQ-014 [boundary]
696// 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