mirror of https://bitbucket.org/ausocean/av.git
av/stream/flac: saving progress
This commit is contained in:
parent
e557734c83
commit
1104c96a2f
|
@ -38,45 +38,51 @@ const (
|
||||||
outFile = "testOut.wav"
|
outFile = "testOut.wav"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TestWriteSeekerWrite checks that basic writing to the ws works as expected.
|
||||||
func TestWriteSeekerWrite(t *testing.T) {
|
func TestWriteSeekerWrite(t *testing.T) {
|
||||||
writerSeeker := &writeSeeker{}
|
ws := &writeSeeker{}
|
||||||
var ws io.WriteSeeker = writerSeeker
|
|
||||||
|
|
||||||
ws.Write([]byte("hello"))
|
const tstStr1 = "hello"
|
||||||
if string(writerSeeker.buf) != "hello" {
|
ws.Write([]byte(tstStr1))
|
||||||
t.Fail()
|
got := string(ws.buf)
|
||||||
}
|
if got != tstStr1 {
|
||||||
|
t.Errorf("Write failed, got: %v, want: %v", got, tstStr1)
|
||||||
ws.Write([]byte(" world"))
|
|
||||||
if string(writerSeeker.buf) != "hello world" {
|
|
||||||
t.Fail()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tstStr2 = " world"
|
||||||
|
const want = "hello world"
|
||||||
|
ws.Write([]byte(tstStr2))
|
||||||
|
got = string(ws.buf)
|
||||||
|
if got != want {
|
||||||
|
t.Errorf("Second write failed, got: %v, want: %v", got, want)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestWriteSeekerSeek checks that writing and seeking works as expected, i.e. we
|
||||||
|
// can write, then seek to a knew place in the buf, and write again, either replacing
|
||||||
|
// bytes, or appending bytes.
|
||||||
func TestWriteSeekerSeek(t *testing.T) {
|
func TestWriteSeekerSeek(t *testing.T) {
|
||||||
writerSeeker := &writeSeeker{}
|
ws := &writeSeeker{}
|
||||||
var ws io.WriteSeeker = writerSeeker
|
|
||||||
|
|
||||||
ws.Write([]byte("hello"))
|
ws.Write([]byte("hello"))
|
||||||
if string(writerSeeker.buf) != "hello" {
|
if string(ws.buf) != "hello" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.Write([]byte(" world"))
|
ws.Write([]byte(" world"))
|
||||||
if string(writerSeeker.buf) != "hello world" {
|
if string(ws.buf) != "hello world" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.Seek(-2, io.SeekEnd)
|
ws.Seek(-2, io.SeekEnd)
|
||||||
ws.Write([]byte("k!"))
|
ws.Write([]byte("k!"))
|
||||||
if string(writerSeeker.buf) != "hello work!" {
|
if string(ws.buf) != "hello work!" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.Seek(6, io.SeekStart)
|
ws.Seek(6, io.SeekStart)
|
||||||
ws.Write([]byte("gopher"))
|
ws.Write([]byte("gopher"))
|
||||||
if string(writerSeeker.buf) != "hello gopher" {
|
if string(ws.buf) != "hello gopher" {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue