============================================================================= Code MC/DC gap closure tests — round 2 (100% target) ============================================================================= Verifies: SYS-REQ-035 [boundary] Code MC/DC gap: parser.go:813 Delete conjunction Full MC/D
(t *testing.T)
| 778 | // (T,F,_) => F : delete middle key (remainder starts with quote) |
| 779 | // (T,T,F) => F : delete single key (prevTok is '{') |
| 780 | func TestCodeMCDC_DeleteConjunctionFullMCDC(t *testing.T) { |
| 781 | t.Run("TTT: trailing comma malformed JSON", func(t *testing.T) { |
| 782 | // {"a":1,"b":2,} — after deleting "b", the comma after "2" advances |
| 783 | // endOffset past it, so remainedValue = "}". prevTok is the comma |
| 784 | // before "b" key. All three conditions TRUE => trailing comma removed. |
| 785 | got := string(Delete([]byte(`{"a":1,"b":2,}`), "b")) |
| 786 | if got != `{"a":1}` { |
| 787 | t.Fatalf("Delete TTT = %q, want %q", got, `{"a":1}`) |
| 788 | } |
| 789 | }) |
| 790 | |
| 791 | t.Run("F: malformed whitespace-only remainder", func(t *testing.T) { |
| 792 | // {"a":1, — after deleting "a", remainder is all whitespace. |
| 793 | // nextToken returns -1, so remainedTok > -1 is FALSE. |
| 794 | got := string(Delete([]byte(`{"a":1, `), "a")) |
| 795 | _ = got // Accept any result for malformed input; no panic is the requirement. |
| 796 | }) |
| 797 | |
| 798 | t.Run("TF: delete middle key", func(t *testing.T) { |
| 799 | // {"a":1,"b":2,"c":3} — after deleting "b", remainder starts |
| 800 | // with "c":3}, nextToken finds '"' not '}'. Second condition FALSE. |
| 801 | got := string(Delete([]byte(`{"a":1,"b":2,"c":3}`), "b")) |
| 802 | if got != `{"a":1,"c":3}` { |
| 803 | t.Fatalf("Delete TF = %q, want %q", got, `{"a":1,"c":3}`) |
| 804 | } |
| 805 | }) |
| 806 | |
| 807 | t.Run("TTF: delete single key", func(t *testing.T) { |
| 808 | // {"a":1} — after deleting "a", remainder = "}", |
| 809 | // remainedValue[0]=='}'=TRUE, but prevTok is '{' not ','. Third FALSE. |
| 810 | got := string(Delete([]byte(`{"a":1}`), "a")) |
| 811 | if got != `{}` { |
| 812 | t.Fatalf("Delete TTF = %q, want %q", got, `{}`) |
| 813 | } |
| 814 | }) |
| 815 | } |
| 816 | |
| 817 | // Verifies: SYS-REQ-001 [boundary] |
| 818 | // Code MC/DC gap: parser.go:289 searchKeys keyLevel == level-1 |