| 17 | ) |
| 18 | |
| 19 | func TestPatchString(t *testing.T) { |
| 20 | type TestCase struct { |
| 21 | Patch Patch |
| 22 | |
| 23 | Expected string |
| 24 | } |
| 25 | |
| 26 | for i, tc := range []TestCase{ |
| 27 | { |
| 28 | Patch: Patch{ |
| 29 | Start1: 20, |
| 30 | Start2: 21, |
| 31 | Length1: 18, |
| 32 | Length2: 17, |
| 33 | |
| 34 | diffs: []Diff{ |
| 35 | {DiffEqual, "jump"}, |
| 36 | {DiffDelete, "s"}, |
| 37 | {DiffInsert, "ed"}, |
| 38 | {DiffEqual, " over "}, |
| 39 | {DiffDelete, "the"}, |
| 40 | {DiffInsert, "a"}, |
| 41 | {DiffEqual, "\nlaz"}, |
| 42 | }, |
| 43 | }, |
| 44 | |
| 45 | Expected: "@@ -21,18 +22,17 @@\n jump\n-s\n+ed\n over \n-the\n+a\n %0Alaz\n", |
| 46 | }, |
| 47 | } { |
| 48 | actual := tc.Patch.String() |
| 49 | assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc)) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func TestPatchFromText(t *testing.T) { |
| 54 | type TestCase struct { |