From 071d96f16dc2682f90529c0837f61317688e0266 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 18 Aug 2022 15:48:22 +0900 Subject: [PATCH] audio/vorbis: test Length with a non-seekable source Updates #2252 --- audio/vorbis/vorbis.go | 2 ++ audio/vorbis/vorbis_test.go | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/audio/vorbis/vorbis.go b/audio/vorbis/vorbis.go index a115999c7..a8d4caa6f 100644 --- a/audio/vorbis/vorbis.go +++ b/audio/vorbis/vorbis.go @@ -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 } diff --git a/audio/vorbis/vorbis_test.go b/audio/vorbis/vorbis_test.go index ca3881962..fe0632486 100644 --- a/audio/vorbis/vorbis_test.go +++ b/audio/vorbis/vorbis_test.go @@ -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) + } }