av/stream/flac: cleaned up testing file

This commit is contained in:
saxon 2019-01-22 12:14:40 +10:30
parent 1104c96a2f
commit 3f41c7b72b
1 changed files with 26 additions and 12 deletions

View File

@ -64,29 +64,43 @@ func TestWriteSeekerWrite(t *testing.T) {
func TestWriteSeekerSeek(t *testing.T) {
ws := &writeSeeker{}
ws.Write([]byte("hello"))
if string(ws.buf) != "hello" {
t.Fail()
const tstStr1 = "hello"
want1 := tstStr1
ws.Write([]byte(tstStr1))
got := string(ws.buf)
if got != tstStr1 {
t.Errorf("Unexpected output, got: %v, want: %v", got, want1)
}
ws.Write([]byte(" world"))
if string(ws.buf) != "hello world" {
t.Fail()
const tstStr2 = " world"
const want2 = tstStr1 + tstStr2
ws.Write([]byte(tstStr2))
got = string(ws.buf)
if got != want2 {
t.Errorf("Unexpected output, got: %v, want: %v", got, want2)
}
const tstStr3 = "k!"
const want3 = "hello work!"
ws.Seek(-2, io.SeekEnd)
ws.Write([]byte("k!"))
if string(ws.buf) != "hello work!" {
t.Fail()
ws.Write([]byte(tstStr3))
got = string(ws.buf)
if got != want3 {
t.Errorf("Unexpected output, got: %v, want: %v", got, want3)
}
const tstStr4 = "gopher"
const want4 = "hello gopher"
ws.Seek(6, io.SeekStart)
ws.Write([]byte("gopher"))
if string(ws.buf) != "hello gopher" {
t.Fail()
ws.Write([]byte(tstStr4))
got = string(ws.buf)
if got != want4 {
t.Errorf("Unexpected output, got: %v, want: %v", got, want4)
}
}
// TestDecodeFlac checks that we can load a flac file and decode to wav, writing
// to a wav file.
func TestDecodeFlac(t *testing.T) {
b, err := ioutil.ReadFile(testFile)
if err != nil {