audio/vorbis: test Length with a non-seekable source

Updates #2252
This commit is contained in:
Hajime Hoshi 2022-08-18 15:48:22 +09:00
parent 4d03b9fd98
commit 33616600e4
2 changed files with 8 additions and 1 deletions

View File

@ -44,6 +44,8 @@ func (s *Stream) Seek(offset int64, whence int) (int64, error) {
}
// Length returns the size of decoded stream in bytes.
//
// If the source is not io.Seeker, Length returns 0.
func (s *Stream) Length() int64 {
return s.size
}

View File

@ -83,5 +83,10 @@ func TestNonSeeker(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_ = s
got := s.Length()
want := int64(0)
if got != want {
t.Errorf("s.Length(): got: %d, want: %d", got, want)
}
}