6 "github.com/anacrolix/missinggo/v2/bitmap"
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 bitmap.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) {
59 name: "FileInFirstPiece",