-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathkind_test.go
35 lines (33 loc) · 929 Bytes
/
kind_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
package mp4
import (
"bytes"
"encoding/hex"
"testing"
)
func TestKind(t *testing.T) {
t.Run("encode and decode", func(t *testing.T) {
kind := &KindBox{SchemeURI: "urn:mpeg:dash:role:2011", Value: "forced-subtitle"}
boxDiffAfterEncodeAndDecode(t, kind)
})
t.Run("decode with full box header", func(t *testing.T) {
rawHex := ("000000296b696e64" +
"0000000075726e3a6d7065673a646173" +
"683a726f6c653a32303131006d61696e00")
rawBytes, err := hex.DecodeString(rawHex)
if err != nil {
t.Error(err)
}
buffer := bytes.NewReader(rawBytes)
box, err := DecodeBox(0, buffer)
if err != nil {
t.Errorf("Error decoding kind box: %v", err)
}
kind := box.(*KindBox)
if kind.SchemeURI != "urn:mpeg:dash:role:2011" {
t.Errorf("Expected scheme URI 'urn:mpeg:dash:role:2011', got '%s'", kind.SchemeURI)
}
if kind.Value != "main" {
t.Errorf("Expected value 'main', got '%s'", kind.Value)
}
})
}