8 check "gopkg.in/check.v1"
11 // Gocheck boilerplate
12 func Test(t *testing.T) {
16 var _ = check.Suite(&CollisionSuite{})
18 type CollisionSuite struct{}
20 func (s *CollisionSuite) TestCollisionOrCorrupt(c *check.C) {
21 fooMD5 := "acbd18db4cc2f85cedef654fccc4a4d8"
23 c.Check(collisionOrCorrupt(fooMD5, []byte{'f'}, []byte{'o'}, bytes.NewBufferString("o")),
24 check.Equals, CollisionError)
25 c.Check(collisionOrCorrupt(fooMD5, []byte{'f'}, nil, bytes.NewBufferString("oo")),
26 check.Equals, CollisionError)
27 c.Check(collisionOrCorrupt(fooMD5, []byte{'f'}, []byte{'o', 'o'}, nil),
28 check.Equals, CollisionError)
29 c.Check(collisionOrCorrupt(fooMD5, nil, []byte{}, bytes.NewBufferString("foo")),
30 check.Equals, CollisionError)
31 c.Check(collisionOrCorrupt(fooMD5, []byte{'f', 'o', 'o'}, nil, bytes.NewBufferString("")),
32 check.Equals, CollisionError)
33 c.Check(collisionOrCorrupt(fooMD5, nil, nil, iotest.NewReadLogger("foo: ", iotest.DataErrReader(iotest.OneByteReader(bytes.NewBufferString("foo"))))),
34 check.Equals, CollisionError)
36 c.Check(collisionOrCorrupt(fooMD5, []byte{'f', 'o', 'o'}, nil, bytes.NewBufferString("bar")),
37 check.Equals, DiskHashError)
38 c.Check(collisionOrCorrupt(fooMD5, []byte{'f', 'o'}, nil, nil),
39 check.Equals, DiskHashError)
40 c.Check(collisionOrCorrupt(fooMD5, []byte{}, nil, bytes.NewBufferString("")),
41 check.Equals, DiskHashError)
42 c.Check(collisionOrCorrupt(fooMD5, []byte{'f', 'O'}, nil, bytes.NewBufferString("o")),
43 check.Equals, DiskHashError)
44 c.Check(collisionOrCorrupt(fooMD5, []byte{'f', 'O', 'o'}, nil, nil),
45 check.Equals, DiskHashError)
46 c.Check(collisionOrCorrupt(fooMD5, []byte{'f', 'o'}, []byte{'O'}, nil),
47 check.Equals, DiskHashError)
48 c.Check(collisionOrCorrupt(fooMD5, []byte{'f', 'o'}, nil, bytes.NewBufferString("O")),
49 check.Equals, DiskHashError)
51 c.Check(collisionOrCorrupt(fooMD5, []byte{}, nil, iotest.TimeoutReader(iotest.OneByteReader(bytes.NewBufferString("foo")))),
52 check.Equals, iotest.ErrTimeout)