Add 'x/' from commit 'a10a11b9d371f36b7c3510da32a1d70b74e27bd1'
git-subtree-dir: x git-subtree-mainline:7d05a6ee8fgit-subtree-split:a10a11b9d3
This commit is contained in:
37
x/utils/upload/upload_test.go
Normal file
37
x/utils/upload/upload_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package upload
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"kr.dev/diff"
|
||||
)
|
||||
|
||||
func TestChunks(t *testing.T) {
|
||||
const size = 101
|
||||
const chunkSize = 10
|
||||
var got []Chunk[int]
|
||||
var lastN int
|
||||
for n, c := range Chunks(size, chunkSize) {
|
||||
if n != lastN+1 {
|
||||
t.Errorf("n = %d; want %d", n, lastN+1)
|
||||
}
|
||||
got = append(got, c)
|
||||
lastN = n
|
||||
}
|
||||
|
||||
want := []Chunk[int]{
|
||||
{0, 10},
|
||||
{10, 10},
|
||||
{20, 10},
|
||||
{30, 10},
|
||||
{40, 10},
|
||||
{50, 10},
|
||||
{60, 10},
|
||||
{70, 10},
|
||||
{80, 10},
|
||||
{90, 10},
|
||||
{100, 1},
|
||||
}
|
||||
|
||||
diff.Test(t, t.Errorf, got, want)
|
||||
}
|
||||
Reference in New Issue
Block a user