-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathmeta_test.go
56 lines (52 loc) · 1.19 KB
/
meta_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
package mp4
import (
"bytes"
"encoding/hex"
"strings"
"testing"
"github.com/Eyevinn/mp4ff/bits"
)
func TestMeta(t *testing.T) {
hdlr, err := CreateHdlr("zzzz")
if err != nil {
t.Error(err)
}
meta := CreateMetaBox(0, hdlr)
boxDiffAfterEncodeAndDecode(t, meta)
}
func TestQuickTimeMeta(t *testing.T) {
quickTimeMetaAtom := (`000000416d6574610000002168646c7200000000000000006d64746100000000` +
`000000000000000000000000106b657973000000000000000000000008696c7374`)
data, err := hex.DecodeString(quickTimeMetaAtom)
if err != nil {
t.Error(err)
}
sr := bits.NewFixedSliceReader(data)
box, err := DecodeBoxSR(0, sr)
if err != nil {
t.Error(err)
}
meta, ok := box.(*MetaBox)
if !ok {
t.Error("box is not meta")
}
if !meta.IsQuickTime() {
t.Errorf("meta box not detected as QuickTime")
}
info := bytes.Buffer{}
err = meta.Info(&info, "", "", "")
if err != nil {
t.Error(err)
}
if !strings.Contains(info.String(), "is QuickTime meta atom") {
t.Error("lacks QuickTime in info string")
}
outBuf := bytes.Buffer{}
err = meta.Encode(&outBuf)
if err != nil {
t.Error(err)
}
if !bytes.Equal(data, outBuf.Bytes()) {
t.Errorf("output meta for QuickTime differs from input")
}
}