Skip to content

Commit

Permalink
tests: test header is omitted if file names are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
pmezard committed Jan 10, 2016
1 parent 509b2ff commit 4d60064
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions difflib/difflib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,41 @@ func TestOutputFormatNoTrailingTabOnEmptyFiledate(t *testing.T) {
assertEqual(t, SplitLines(cd)[:2], []string{"*** Original\n", "--- Current\n"})
}

func TestOmitFilenames(t *testing.T) {
diff := UnifiedDiff{
A: SplitLines("o\nn\ne\n"),
B: SplitLines("t\nw\no\n"),
Eol: "\n",
}
ud, err := GetUnifiedDiffString(diff)
assertEqual(t, err, nil)
assertEqual(t, SplitLines(ud), []string{
"@@ -0,0 +1,2 @@\n",
"+t\n",
"+w\n",
"@@ -2,2 +3,0 @@\n",
"-n\n",
"-e\n",
"\n",
})

cd, err := GetContextDiffString(ContextDiff(diff))
assertEqual(t, err, nil)
assertEqual(t, SplitLines(cd), []string{
"***************\n",
"*** 0 ****\n",
"--- 1,2 ----\n",
"+ t\n",
"+ w\n",
"***************\n",
"*** 2,3 ****\n",
"- n\n",
"- e\n",
"--- 3 ----\n",
"\n",
})
}

func TestSplitLines(t *testing.T) {
allTests := []struct {
input string
Expand Down

0 comments on commit 4d60064

Please sign in to comment.