mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
audio: Add test for negative position
This commit is contained in:
parent
0d5924b448
commit
6a1afe8fbe
@ -60,6 +60,9 @@ func (i *InfiniteLoop) Seek(offset int64, whence int) (int64, error) {
|
||||
case io.SeekEnd:
|
||||
return 0, fmt.Errorf("audio: whence must be io.SeekStart or io.SeekCurrent for InfiniteLoop")
|
||||
}
|
||||
if next < 0 {
|
||||
return 0, fmt.Errorf("audio: position must >= 0")
|
||||
}
|
||||
next %= i.size
|
||||
pos, err := i.stream.Seek(next, io.SeekStart)
|
||||
if err != nil {
|
||||
|
@ -72,4 +72,9 @@ func TestInfiniteLoop(t *testing.T) {
|
||||
t.Errorf("index: %d, got: %v, want: %v", i, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// Seek to negative position is an error.
|
||||
if _, err := l.Seek(-1, io.SeekStart); err == nil {
|
||||
t.Errorf("got: %v, want: %v", err, nil)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user