File: section_read_seeker_test.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 836 kB
  • sloc: makefile: 4
file content (27 lines) | stat: -rw-r--r-- 582 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package missinggo

import (
	"bytes"
	"io"
	"os"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestSectionReadSeekerReadBeyondEnd(t *testing.T) {
	base := bytes.NewReader([]byte{1, 2, 3})
	srs := NewSectionReadSeeker(base, 1, 1)
	dest := new(bytes.Buffer)
	n, err := io.Copy(dest, srs)
	assert.EqualValues(t, 1, n)
	assert.NoError(t, err)
}

func TestSectionReadSeekerSeekEnd(t *testing.T) {
	base := bytes.NewReader([]byte{1, 2, 3})
	srs := NewSectionReadSeeker(base, 1, 1)
	off, err := srs.Seek(0, os.SEEK_END)
	assert.NoError(t, err)
	assert.EqualValues(t, 1, off)
}