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

Function TestCodeMCDC_DeleteTrailingCommaRemoval

mcdc_supplement_test.go:495–511  ·  view source on GitHub ↗

============================================================================= Code MC/DC gap closure tests ============================================================================= Verifies: SYS-REQ-035 [boundary] Code MC/DC gap: parser.go:810 Delete Drive nextToken(remainedValue) > -1 to TRUE s

(t *testing.T)

Source from the content-addressed store, hash-verified

493// conjunction are evaluated. This requires deleting the last field in an
494// object where a trailing comma precedes the closing brace.
495func TestCodeMCDC_DeleteTrailingCommaRemoval(t *testing.T) {
496 // Delete the last key "b" from {"a":1,"b":2}.
497 // After removing "b":2, remainedValue starts with "}", nextToken > -1,
498 // remainedValue[nextToken] == '}', and data[prevTok] == ','.
499 // This exercises the TRUE branch of the conjunction at line 810.
500 got := string(Delete([]byte(`{"a":1,"b":2}`), "b"))
501 if got != `{"a":1}` {
502 t.Fatalf("Delete trailing comma removal = %q, want %q", got, `{"a":1}`)
503 }
504
505 // Also test deleting a middle key so the conjunction is FALSE
506 // (nextToken > -1 is TRUE but remainedValue[nextToken] != '}').
507 got2 := string(Delete([]byte(`{"a":1,"b":2,"c":3}`), "b"))
508 if got2 != `{"a":1,"c":3}` {
509 t.Fatalf("Delete middle key = %q, want %q", got2, `{"a":1,"c":3}`)
510 }
511}
512
513// Verifies: SYS-REQ-001 [boundary]
514// Code MC/DC gap: parser.go:325 searchKeys

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…