mirror of https://bitbucket.org/ausocean/av.git
av/stream/flac: added writeseeker tests
This commit is contained in:
parent
6f1767d152
commit
b5611bb2b4
|
@ -27,6 +27,7 @@ LICENSE
|
|||
package flac
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -37,6 +38,49 @@ const (
|
|||
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) {
|
||||
b, err := ioutil.ReadFile(testFile)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue