mirror of https://bitbucket.org/ausocean/av.git
container/flv/audio_test.go: added test TestAudioTagBytes
Wrote test TestAudioTagBytes to check that we can correctly get a []byte representation of an AudioTag.
This commit is contained in:
parent
48645d1cf3
commit
553ba8dc54
|
@ -73,5 +73,39 @@ func TestVideoTagBytes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAudioTagBytes(t *testing.T) {
|
||||
tests := []struct {
|
||||
tag AudioTag
|
||||
expected []byte
|
||||
}{
|
||||
{
|
||||
tag: AudioTag{
|
||||
TagType: AudioTagType,
|
||||
DataSize: 8,
|
||||
Timestamp: 1234,
|
||||
TimestampExtended: 56,
|
||||
SoundFormat: AACAudioFormat,
|
||||
SoundRate: 3,
|
||||
SoundSize: true,
|
||||
SoundType: true,
|
||||
Data: []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07},
|
||||
},
|
||||
expected: []byte{
|
||||
0x08, // TagType.
|
||||
0x00, 0x00, 0x08, // DataSize.
|
||||
0x00, 0x04, 0xd2, // Timestamp.
|
||||
0x38, // TimestampExtended.
|
||||
0x00, 0x00, 0x00, // StreamID. (always 0)
|
||||
0xaf, // SoundFormat=1010,SoundRate=11,SoundSize=1,SoundType=1
|
||||
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // AudioData.
|
||||
0x00, 0x00, 0x00, 0x00, // previousTagSize.
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for testNum, test := range tests {
|
||||
got := test.tag.Bytes()
|
||||
if !bytes.Equal(got, test.expected) {
|
||||
t.Errorf("did not get expected result for test: %v.\n Got: %v\n Want: %v\n", testNum, got, test.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue