| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package compare_test |
| 6 |
|
| 7 |
import ( |
| 8 |
"testing" |
| 9 |
|
| 10 |
"golang.org/x/tools/gopls/internal/test/compare" |
| 11 |
) |
| 12 |
|
| 13 |
func TestText(t *testing.T) { |
| 14 |
tests := []struct { |
| 15 |
got, want, wantDiff string |
| 16 |
}{ |
| 17 |
{"", "", ""}, |
| 18 |
{"equal", "equal", ""}, |
| 19 |
{"a", "b", "--- want\n+++ got\n@@ -1 +1 @@\n-b\n+a\n"}, |
| 20 |
{"a\nd\nc\n", "a\nb\nc\n", "--- want\n+++ got\n@@ -1,4 +1,4 @@\n a\n-b\n+d\n c\n \n"}, |
| 21 |
} |
| 22 |
|
| 23 |
for _, test := range tests { |
| 24 |
if gotDiff := compare.Text(test.want, test.got); gotDiff != test.wantDiff { |
| 25 |
t.Errorf("compare.Text(%q, %q) =\n%q, want\n%q", test.want, test.got, gotDiff, test.wantDiff) |
| 26 |
} |
| 27 |
} |
| 28 |
} |