(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestParseHunkHeader(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | header string |
| 15 | oldS, oldC int |
| 16 | newS, newC int |
| 17 | ok bool |
| 18 | }{ |
| 19 | {"@@ -10,3 +14,2 @@", 10, 3, 14, 2, true}, |
| 20 | {"@@ -1 +1 @@", 1, 1, 1, 1, true}, |
| 21 | {"@@ -1,0 +5,3 @@ ctx", 1, 0, 5, 3, true}, |
| 22 | {"@@ malformed", 0, 0, 0, 0, false}, |
| 23 | } |
| 24 | for _, tc := range tests { |
| 25 | t.Run(tc.header, func(t *testing.T) { |
| 26 | oS, oC, nS, nC, ok := parseHunkHeader(tc.header) |
| 27 | assert.Equal(t, tc.ok, ok) |
| 28 | if tc.ok { |
| 29 | assert.Equal(t, tc.oldS, oS) |
| 30 | assert.Equal(t, tc.oldC, oC) |
| 31 | assert.Equal(t, tc.newS, nS) |
| 32 | assert.Equal(t, tc.newC, nC) |
| 33 | } |
| 34 | }) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestParseUnifiedDiff_AdditionsAndDeletions(t *testing.T) { |
| 39 | raw := strings.Join([]string{ |
nothing calls this directly
no test coverage detected