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 5bc1460648
commit 071d96f16d
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. // Length returns the size of decoded stream in bytes.
//
// If the source is not io.Seeker, Length returns 0.
func (s *Stream) Length() int64 { func (s *Stream) Length() int64 {
return s.size return s.size
} }

View File

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