+
+ // If WriteTo stops early due to a write error, return the
+ // write error (not "bad checksum").
+ {
+ input := bytes.NewBuffer(make([]byte, 1<<26))
+ hcr := HashCheckingReader{input, md5.New(), hash}
+ r, w := io.Pipe()
+ r.Close()
+ n, err := hcr.WriteTo(w)
+ c.Check(n, Equals, int64(0))
+ c.Check(err, NotNil)
+ c.Check(err, Not(Equals), BadChecksum)
+ }