TestDiffLinesParityWithDifflib verifies that diffLines produces identical output to difflib.Diff across a variety of inputs, ensuring the linear-space implementation is a drop-in replacement.
(t *testing.T)
| 13 | // output to difflib.Diff across a variety of inputs, ensuring the |
| 14 | // linear-space implementation is a drop-in replacement. |
| 15 | func TestDiffLinesParityWithDifflib(t *testing.T) { |
| 16 | cases := []struct { |
| 17 | name string |
| 18 | seq1 []string |
| 19 | seq2 []string |
| 20 | }{ |
| 21 | { |
| 22 | name: "both empty", |
| 23 | seq1: nil, |
| 24 | seq2: nil, |
| 25 | }, |
| 26 | { |
| 27 | name: "first empty", |
| 28 | seq1: nil, |
| 29 | seq2: []string{"a", "b"}, |
| 30 | }, |
| 31 | { |
| 32 | name: "second empty", |
| 33 | seq1: []string{"a", "b"}, |
| 34 | seq2: nil, |
| 35 | }, |
| 36 | { |
| 37 | name: "identical", |
| 38 | seq1: []string{"a", "b", "c"}, |
| 39 | seq2: []string{"a", "b", "c"}, |
| 40 | }, |
| 41 | { |
| 42 | name: "completely different", |
| 43 | seq1: []string{"a", "b", "c"}, |
| 44 | seq2: []string{"x", "y", "z"}, |
| 45 | }, |
| 46 | { |
| 47 | name: "common prefix only", |
| 48 | seq1: []string{"a", "b", "c"}, |
| 49 | seq2: []string{"a", "b", "d"}, |
| 50 | }, |
| 51 | { |
| 52 | name: "common suffix only", |
| 53 | seq1: []string{"a", "b", "c"}, |
| 54 | seq2: []string{"x", "b", "c"}, |
| 55 | }, |
| 56 | { |
| 57 | name: "interleaved changes", |
| 58 | seq1: []string{"line1", "line2", "line3", "line4", "line5"}, |
| 59 | seq2: []string{"line1-changed", "line2", "line3-changed", "line4", "line5-changed"}, |
| 60 | }, |
| 61 | { |
| 62 | name: "insertions", |
| 63 | seq1: []string{"a", "c"}, |
| 64 | seq2: []string{"a", "b", "c"}, |
| 65 | }, |
| 66 | { |
| 67 | name: "deletions", |
| 68 | seq1: []string{"a", "b", "c"}, |
| 69 | seq2: []string{"a", "c"}, |
| 70 | }, |
| 71 | { |
| 72 | name: "repeated elements", |
nothing calls this directly
no test coverage detected