Skip to content

Commit

Permalink
Merge pull request #70 from maksimov/master
Browse files Browse the repository at this point in the history
Added more tests to improve coverage slightly
  • Loading branch information
zimmski committed Dec 5, 2016
2 parents 0aae786 + fa26729 commit 83532ca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions diffmatchpatch/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,29 @@ func TestDiffDelta(t *testing.T) {
deltaDiffs, err = dmp.DiffFromDelta("", delta)
assert.Equal(t, diffs, deltaDiffs)
assert.Nil(t, err)

// Test blank tokens.
_, err = dmp.DiffFromDelta("", "")
assert.Nil(t, err)

// Test invalid diff operation "a"
_, err = dmp.DiffFromDelta("", "a")
if err == nil {
assert.Fail(t, "expected Invalid diff operation.")
}

// Test non-numeric parameter
_, err = dmp.DiffFromDelta("", "-")
if err == nil {
assert.Fail(t, "expected Invalid syntax.")
}

// Test negative parameter
_, err = dmp.DiffFromDelta("", "--1")
if err == nil {
assert.Fail(t, "expected Negative number.")
}

}

func TestDiffXIndex(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions diffmatchpatch/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestPatchFromText(t *testing.T) {
{"@@ -1 +1 @@\n-a\n+b\n", ""},
{"@@ -1,3 +0,0 @@\n-abc\n", ""},
{"@@ -0,0 +1,3 @@\n+abc\n", ""},
{"@@ _0,0 +0,0 @@\n+abc\n", "Invalid patch string: @@ _0,0 +0,0 @@"},
{"Bad\nPatch\n", "Invalid patch string"},
} {
patches, err := dmp.PatchFromText(tc.Patch)
Expand Down Expand Up @@ -201,6 +202,10 @@ func TestPatchMakeAndPatchToText(t *testing.T) {

actual := dmp.PatchToText(patches)
assert.Equal(t, "@@ -1,14 +1,16 @@\n Lorem \n+a \n ipsum do\n@@ -148,13 +148,12 @@\n m libero\n- \n vel.\n", actual)

// Check that empty Patch array is returned for no parameter call
patches = dmp.PatchMake()
assert.Equal(t, []Patch{}, patches)
}

func TestPatchSplitMax(t *testing.T) {
Expand Down

0 comments on commit 83532ca

Please sign in to comment.