diff options
Diffstat (limited to 'plumbing/format/packfile/delta_test.go')
-rw-r--r-- | plumbing/format/packfile/delta_test.go | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/plumbing/format/packfile/delta_test.go b/plumbing/format/packfile/delta_test.go index 9ee3499..42b777a 100644 --- a/plumbing/format/packfile/delta_test.go +++ b/plumbing/format/packfile/delta_test.go @@ -1,7 +1,6 @@ package packfile import ( - "fmt" "math/rand" . "gopkg.in/check.v1" @@ -86,9 +85,28 @@ func (s *DeltaSuite) TestAddDelta(c *C) { baseBuf := genBytes(t.base) targetBuf := genBytes(t.target) delta := DiffDelta(baseBuf, targetBuf) - result := PatchDelta(baseBuf, delta) + result, err := PatchDelta(baseBuf, delta) - c.Log(fmt.Printf("Executing test case: %s\n", t.description)) + c.Log("Executing test case:", t.description) + c.Assert(err, IsNil) c.Assert(result, DeepEquals, targetBuf) } } + +func (s *DeltaSuite) TestIncompleteDelta(c *C) { + for _, t := range s.testCases { + c.Log("Incomplete delta on:", t.description) + baseBuf := genBytes(t.base) + targetBuf := genBytes(t.target) + delta := DiffDelta(baseBuf, targetBuf) + delta = delta[:len(delta)-2] + result, err := PatchDelta(baseBuf, delta) + c.Assert(err, NotNil) + c.Assert(result, IsNil) + } + + // check nil input too + result, err := PatchDelta(nil, nil) + c.Assert(err, NotNil) + c.Assert(result, IsNil) +} |