6 "github.com/RoaringBitmap/roaring"
7 "github.com/stretchr/testify/assert"
10 func TestFileExclusivePieces(t *testing.T) {
11 for _, _case := range []struct {
12 off, size, pieceSize int64
19 begin, end := byteRegionExclusivePieces(_case.off, _case.size, _case.pieceSize)
20 assert.EqualValues(t, _case.begin, begin)
21 assert.EqualValues(t, _case.end, end)
25 type testFileBytesLeft struct {
31 completedPieces roaring.Bitmap
36 func (me testFileBytesLeft) Run(t *testing.T) {
37 t.Run(me.name, func(t *testing.T) {
38 assert.EqualValues(t, me.expected, fileBytesLeft(me.usualPieceSize, me.firstPieceIndex, me.endPieceIndex, me.fileOffset, me.fileLength, &me.completedPieces))
42 func TestFileBytesLeft(t *testing.T) {
50 name: "ZeroLengthFile",
60 name: "EndOfSecondPiece",
70 name: "FileInFirstPiece",
110 completedPieces: func() (ret roaring.Bitmap) {
114 name: "ThreePiecesCompletedAll",