Fix reusing chunker

This commit is contained in:
Alexander Neumann 2014-12-03 23:20:45 +01:00
parent 4b6c7f1584
commit 9dc0bf6378
2 changed files with 11 additions and 0 deletions

View File

@ -90,6 +90,7 @@ func (c *Chunker) reset() {
for i := 0; i < WindowSize; i++ {
c.window[i] = 0
}
c.closed = false
c.digest = 0
c.wpos = 0
c.pos = 0

View File

@ -126,6 +126,16 @@ func TestChunker(t *testing.T) {
ch.Free()
}
func TestChunkerReuse(t *testing.T) {
// test multiple uses of the same chunker
for i := 0; i < 4; i++ {
buf := get_random(23, 32*1024*1024)
ch := chunker.New(bytes.NewReader(buf))
test_with_data(t, ch, chunks1)
ch.Free()
}
}
func BenchmarkChunker(b *testing.B) {
size := 10 * 1024 * 1024
buf := get_random(23, size)