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

Function TestCodeMCDC_DeleteTrailingCommaRemoval

mcdc_supplement_test.go:499–515  ·  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

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

Callers

nothing calls this directly

Calls 1

DeleteFunction · 0.85

Tested by

no test coverage detected