@cryptotaxi247 / kubo / commits / c29f62890

add test for overallocation in chunker

License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Dec 19, 2017 at 19:29 UTC c29f6289072eaae353a04616ef49645d9d54c146
1 file changed +14
importer/chunk/splitting_test.go
+14
@@ -22,6 +22,20 @@ func copyBuf(buf []byte) []byte {
22 return cpy
23 }
24
25 +func TestSizeSplitterOverAllocate(t *testing.T) {
26 + max := 1000
27 + r := bytes.NewReader(randBuf(t, max))
28 + chunksize := int64(1024 * 256)
29 + splitter := NewSizeSplitter(r, chunksize)
30 + chunk, err := splitter.NextBytes()
31 + if err != nil {
32 + t.Fatal(err)
33 + }
34 + if cap(chunk) > len(chunk) {
35 + t.Fatal("chunk capacity too large")
36 + }
37 +}
38 +
39 func TestSizeSplitterIsDeterministic(t *testing.T) {
40 if testing.Short() {
41 t.SkipNow()