(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestComputeLineDiff(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | name string |
| 13 | old []string |
| 14 | new []string |
| 15 | wantLen int |
| 16 | wantAdds int |
| 17 | wantDels int |
| 18 | }{ |
| 19 | { |
| 20 | name: "both empty", |
| 21 | old: nil, |
| 22 | new: nil, |
| 23 | wantLen: 0, |
| 24 | wantAdds: 0, |
| 25 | wantDels: 0, |
| 26 | }, |
| 27 | { |
| 28 | name: "identical single line", |
| 29 | old: []string{"hello"}, |
| 30 | new: []string{"hello"}, |
| 31 | wantLen: 1, |
| 32 | wantAdds: 0, |
| 33 | wantDels: 0, |
| 34 | }, |
| 35 | { |
| 36 | name: "add lines to empty", |
| 37 | old: []string{}, |
| 38 | new: []string{"a", "b"}, |
| 39 | wantLen: 2, |
| 40 | wantAdds: 2, |
| 41 | wantDels: 0, |
| 42 | }, |
| 43 | { |
| 44 | name: "delete all lines", |
| 45 | old: []string{"a", "b"}, |
| 46 | new: []string{}, |
| 47 | wantLen: 2, |
| 48 | wantAdds: 0, |
| 49 | wantDels: 2, |
| 50 | }, |
| 51 | { |
| 52 | name: "replace single line", |
| 53 | old: []string{"old"}, |
| 54 | new: []string{"new"}, |
| 55 | wantLen: 2, |
| 56 | wantAdds: 1, |
| 57 | wantDels: 1, |
| 58 | }, |
| 59 | { |
| 60 | name: "insert in middle", |
| 61 | old: []string{"a", "c"}, |
| 62 | new: []string{"a", "b", "c"}, |
| 63 | wantLen: 3, |
| 64 | wantAdds: 1, |
| 65 | wantDels: 0, |
| 66 | }, |
| 67 | { |
nothing calls this directly
no test coverage detected