MCPcopy Create free account
hub / github.com/sergi/go-diff / TestDiffPrettyText

Function TestDiffPrettyText

diffmatchpatch/diff_test.go:1017–1051  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1015}
1016
1017func TestDiffPrettyText(t *testing.T) {
1018 type TestCase struct {
1019 Diffs []Diff
1020
1021 Expected string
1022 }
1023
1024 dmp := New()
1025
1026 for i, tc := range []TestCase{
1027 {
1028 Diffs: []Diff{
1029 {DiffEqual, "a\n"},
1030 {DiffDelete, "<B>b</B>"},
1031 {DiffInsert, "c&d"},
1032 },
1033
1034 Expected: "a\n\x1b[31m<B>b</B>\x1b[0m\x1b[32mc&d\x1b[0m",
1035 },
1036 {
1037 Diffs: []Diff{
1038 {Type: DiffEqual, Text: "a\n"},
1039 {Type: DiffDelete, Text: "b\nc\n"},
1040 {Type: DiffEqual, Text: "def"},
1041 {Type: DiffInsert, Text: "\ng\nh"},
1042 {Type: DiffEqual, Text: "\ni"},
1043 },
1044
1045 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",
1046 },
1047 } {
1048 actual := dmp.DiffPrettyText(tc.Diffs)
1049 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc))
1050 }
1051}
1052
1053func TestDiffText(t *testing.T) {
1054 type TestCase struct {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
DiffPrettyTextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…