| 1051 | } |
| 1052 | |
| 1053 | func TestDiffText(t *testing.T) { |
| 1054 | type TestCase struct { |
| 1055 | Diffs []Diff |
| 1056 | |
| 1057 | ExpectedText1 string |
| 1058 | ExpectedText2 string |
| 1059 | } |
| 1060 | |
| 1061 | dmp := New() |
| 1062 | |
| 1063 | for i, tc := range []TestCase{ |
| 1064 | { |
| 1065 | Diffs: []Diff{ |
| 1066 | {DiffEqual, "jump"}, |
| 1067 | {DiffDelete, "s"}, |
| 1068 | {DiffInsert, "ed"}, |
| 1069 | {DiffEqual, " over "}, |
| 1070 | {DiffDelete, "the"}, |
| 1071 | {DiffInsert, "a"}, |
| 1072 | {DiffEqual, " lazy"}, |
| 1073 | }, |
| 1074 | |
| 1075 | ExpectedText1: "jumps over the lazy", |
| 1076 | ExpectedText2: "jumped over a lazy", |
| 1077 | }, |
| 1078 | } { |
| 1079 | actualText1 := dmp.DiffText1(tc.Diffs) |
| 1080 | assert.Equal(t, tc.ExpectedText1, actualText1, fmt.Sprintf("Test case #%d, %#v", i, tc)) |
| 1081 | |
| 1082 | actualText2 := dmp.DiffText2(tc.Diffs) |
| 1083 | assert.Equal(t, tc.ExpectedText2, actualText2, fmt.Sprintf("Test case #%d, %#v", i, tc)) |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | func TestDiffDelta(t *testing.T) { |
| 1088 | type TestCase struct { |