(t *testing.T)
| 119 | } |
| 120 | |
| 121 | func TestPatchAddContext(t *testing.T) { |
| 122 | type TestCase struct { |
| 123 | Name string |
| 124 | |
| 125 | Patch string |
| 126 | Text string |
| 127 | |
| 128 | Expected string |
| 129 | } |
| 130 | |
| 131 | dmp := New() |
| 132 | dmp.PatchMargin = 4 |
| 133 | |
| 134 | for i, tc := range []TestCase{ |
| 135 | {"Simple case", "@@ -21,4 +21,10 @@\n-jump\n+somersault\n", "The quick brown fox jumps over the lazy dog.", "@@ -17,12 +17,18 @@\n fox \n-jump\n+somersault\n s ov\n"}, |
| 136 | {"Not enough trailing context", "@@ -21,4 +21,10 @@\n-jump\n+somersault\n", "The quick brown fox jumps.", "@@ -17,10 +17,16 @@\n fox \n-jump\n+somersault\n s.\n"}, |
| 137 | {"Not enough leading context", "@@ -3 +3,2 @@\n-e\n+at\n", "The quick brown fox jumps.", "@@ -1,7 +1,8 @@\n Th\n-e\n+at\n qui\n"}, |
| 138 | {"Ambiguity", "@@ -3 +3,2 @@\n-e\n+at\n", "The quick brown fox jumps. The quick brown fox crashes.", "@@ -1,27 +1,28 @@\n Th\n-e\n+at\n quick brown fox jumps. \n"}, |
| 139 | } { |
| 140 | patches, err := dmp.PatchFromText(tc.Patch) |
| 141 | assert.Nil(t, err) |
| 142 | |
| 143 | actual := dmp.PatchAddContext(patches[0], tc.Text) |
| 144 | assert.Equal(t, tc.Expected, actual.String(), fmt.Sprintf("Test case #%d, %s", i, tc.Name)) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func TestPatchMakeAndPatchToText(t *testing.T) { |
| 149 | type TestCase struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…