(t *testing.T)
| 1039 | } |
| 1040 | |
| 1041 | func TestDiffPrettyText(t *testing.T) { |
| 1042 | type TestCase struct { |
| 1043 | Diffs []Diff |
| 1044 | |
| 1045 | Expected string |
| 1046 | } |
| 1047 | |
| 1048 | dmp := New() |
| 1049 | |
| 1050 | for i, tc := range []TestCase{ |
| 1051 | { |
| 1052 | Diffs: []Diff{ |
| 1053 | {DiffEqual, "a\n"}, |
| 1054 | {DiffDelete, "<B>b</B>"}, |
| 1055 | {DiffInsert, "c&d"}, |
| 1056 | }, |
| 1057 | |
| 1058 | Expected: "a\n\x1b[31m<B>b</B>\x1b[0m\x1b[32mc&d\x1b[0m", |
| 1059 | }, |
| 1060 | { |
| 1061 | Diffs: []Diff{ |
| 1062 | {Type: DiffEqual, Text: "a\n"}, |
| 1063 | {Type: DiffDelete, Text: "b\nc\n"}, |
| 1064 | {Type: DiffEqual, Text: "def"}, |
| 1065 | {Type: DiffInsert, Text: "\ng\nh"}, |
| 1066 | {Type: DiffEqual, Text: "\ni"}, |
| 1067 | }, |
| 1068 | |
| 1069 | Expected: "a\n\x1b[31mb\x1b[0m\n\x1b[31mc\x1b[0m\n\x1b[31m\x1b[0mdef\x1b[32m\x1b[0m\n\x1b[32mg\x1b[0m\n\x1b[32mh\x1b[0m\ni", |
| 1070 | }, |
| 1071 | } { |
| 1072 | actual := dmp.DiffPrettyText(tc.Diffs) |
| 1073 | assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc)) |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | func TestDiffText(t *testing.T) { |
| 1078 | type TestCase struct { |
nothing calls this directly
no test coverage detected