-
Notifications
You must be signed in to change notification settings - Fork 84
/
colr_test.go
83 lines (80 loc) · 1.78 KB
/
colr_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package mp4
import (
"bytes"
"testing"
)
func TestColrEncodeDecode(t *testing.T) {
cases := []ColrBox{
{
ColorType: onScreenColors,
ColorPrimaries: 9,
TransferCharacteristics: 16,
MatrixCoefficients: 9,
FullRangeFlag: true,
},
{
ColorType: onScreenColors,
ColorPrimaries: 9,
TransferCharacteristics: 16,
MatrixCoefficients: 9,
FullRangeFlag: false,
},
{
ColorType: restrictedICCType,
ICCProfile: []byte{1, 2, 2, 43, 4},
},
{
ColorType: unrestrictedICCType,
ICCProfile: []byte{1, 2, 2, 43, 4, 5},
},
{
ColorType: quickTimeColorParameters,
ColorPrimaries: 1,
TransferCharacteristics: 1,
MatrixCoefficients: 1,
},
{
ColorType: "xyzd",
UnknownPayload: []byte{0x0, 0x1, 0x0, 0x1},
},
}
for _, tc := range cases {
boxDiffAfterEncodeAndDecode(t, &tc)
}
}
func TestColrInfo(t *testing.T) {
cases := []struct {
cb ColrBox
wanted string
}{
{
cb: ColrBox{
ColorType: onScreenColors,
ColorPrimaries: 9,
TransferCharacteristics: 9,
MatrixCoefficients: 16,
FullRangeFlag: true,
},
wanted: ("[colr] size=19\n - colorType: nclx\n - ColorPrimaries: 9, " +
"TransferCharacteristics: 9, MatrixCoefficients: 16, FullRange: true\n"),
},
{
cb: ColrBox{
ColorType: restrictedICCType,
ICCProfile: []byte{0x02, 0x04},
},
wanted: "[colr] size=14\n - colorType: rICC\n - ICCProfile: 0204\n",
},
}
for _, tc := range cases {
b := bytes.Buffer{}
err := tc.cb.Info(&b, "-1", "", "")
if err != nil {
t.Error(err)
}
gotStr := b.String()
if gotStr != tc.wanted {
t.Errorf("got %q, but wanted %q\n", gotStr, tc.wanted)
}
}
}