-
Notifications
You must be signed in to change notification settings - Fork 31
/
mp4_test.go
34 lines (28 loc) · 1.09 KB
/
mp4_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
package mp4
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestBoxTypeString(t *testing.T) {
assert.Equal(t, "1234", BoxType{'1', '2', '3', '4'}.String())
assert.Equal(t, "abcd", BoxType{'a', 'b', 'c', 'd'}.String())
assert.Equal(t, "xx x", BoxType{'x', 'x', ' ', 'x'}.String())
assert.Equal(t, "xx~x", BoxType{'x', 'x', '~', 'x'}.String())
assert.Equal(t, "xx(c)x", BoxType{'x', 'x', 0xa9, 'x'}.String())
assert.Equal(t, "0x7878ab78", BoxType{'x', 'x', 0xab, 'x'}.String())
}
func TestIsSupported(t *testing.T) {
assert.True(t, StrToBoxType("pssh").IsSupported(Context{}))
assert.False(t, StrToBoxType("1234").IsSupported(Context{}))
}
func TestGetSupportedVersions(t *testing.T) {
vers, err := BoxTypePssh().GetSupportedVersions(Context{})
require.NoError(t, err)
assert.Equal(t, []uint8{0, 1}, vers)
}
func TestIsSupportedVersion(t *testing.T) {
assert.True(t, BoxTypePssh().IsSupportedVersion(0, Context{}))
assert.True(t, BoxTypePssh().IsSupportedVersion(1, Context{}))
assert.False(t, BoxTypePssh().IsSupportedVersion(2, Context{}))
}