forked from sunicy/go-lame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wavfile_test.go
62 lines (59 loc) · 1.26 KB
/
wavfile_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package lame
import (
"github.com/tectiv3/go-lame/compare"
"os"
"testing"
)
func Test_ReadWavHeader(t *testing.T) {
tests := []struct {
fn string
hdr WavHeader
}{
{
fn: "res/1chan_s16ple.wav",
hdr: WavHeader{
ChunkId: chunkIdLe,
WavHeaderRemaining: WavHeaderRemaining{
ChunkSize: 0x04e224,
Format: format,
SubChunk1Id: subChunk1Id,
SubChunk1Size: 16,
AudioFormat: 1,
NumChannels: 1,
SampleRate: 16000,
ByteRate: 32000,
BlockAlign: 2,
BitsPerSample: 16,
SubChunk2Id: subChunk2Id,
SubChunk2Size: 320000,
},
},
},
}
for idx, test := range tests {
t.Run(test.fn, func(t *testing.T) {
f, err := os.OpenFile(test.fn, os.O_RDONLY, 0700)
if err != nil {
t.Errorf("Case#%d, cannot open file %s, err=%s", idx, test.fn, err.Error())
return
}
defer f.Close()
hdr, err := ReadWavHeader(f)
if err != nil {
t.Errorf("Case#%d, %s", idx, err.Error())
return
}
diffs, err := compare.Compare(&test.hdr, &hdr)
if err != nil {
t.Errorf("%s", err.Error())
} else if len(diffs) > 0 {
t.Errorf("%#v", diffs)
}
})
}
}
func Test_LameStruct(t *testing.T) {
l, err := NewLame()
t.Logf("%#v", l.lgs)
t.Logf("%#v", err)
}