mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 09:34:03 +08:00
add test for overallocation in chunker
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
@ -22,6 +22,20 @@ func copyBuf(buf []byte) []byte {
|
|||||||
return cpy
|
return cpy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSizeSplitterOverAllocate(t *testing.T) {
|
||||||
|
max := 1000
|
||||||
|
r := bytes.NewReader(randBuf(t, max))
|
||||||
|
chunksize := int64(1024 * 256)
|
||||||
|
splitter := NewSizeSplitter(r, chunksize)
|
||||||
|
chunk, err := splitter.NextBytes()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if cap(chunk) > len(chunk) {
|
||||||
|
t.Fatal("chunk capacity too large")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSizeSplitterIsDeterministic(t *testing.T) {
|
func TestSizeSplitterIsDeterministic(t *testing.T) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
|
Reference in New Issue
Block a user