av/stream/flac: added writeseeker tests

This commit is contained in:
saxon 2019-01-22 10:45:36 +10:30
parent da5e13bb5d
commit e557734c83
1 changed files with 44 additions and 0 deletions
stream/flac

View File

@ -27,6 +27,7 @@ LICENSE
package flac package flac
import ( import (
"io"
"io/ioutil" "io/ioutil"
"os" "os"
"testing" "testing"
@ -37,6 +38,49 @@ const (
outFile = "testOut.wav" outFile = "testOut.wav"
) )
func TestWriteSeekerWrite(t *testing.T) {
writerSeeker := &writeSeeker{}
var ws io.WriteSeeker = writerSeeker
ws.Write([]byte("hello"))
if string(writerSeeker.buf) != "hello" {
t.Fail()
}
ws.Write([]byte(" world"))
if string(writerSeeker.buf) != "hello world" {
t.Fail()
}
}
func TestWriteSeekerSeek(t *testing.T) {
writerSeeker := &writeSeeker{}
var ws io.WriteSeeker = writerSeeker
ws.Write([]byte("hello"))
if string(writerSeeker.buf) != "hello" {
t.Fail()
}
ws.Write([]byte(" world"))
if string(writerSeeker.buf) != "hello world" {
t.Fail()
}
ws.Seek(-2, io.SeekEnd)
ws.Write([]byte("k!"))
if string(writerSeeker.buf) != "hello work!" {
t.Fail()
}
ws.Seek(6, io.SeekStart)
ws.Write([]byte("gopher"))
if string(writerSeeker.buf) != "hello gopher" {
t.Fail()
}
}
func TestDecodeFlac(t *testing.T) { func TestDecodeFlac(t *testing.T) {
b, err := ioutil.ReadFile(testFile) b, err := ioutil.ReadFile(testFile)
if err != nil { if err != nil {