forked from futzu/cuei
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
126 lines (114 loc) · 2.77 KB
/
example_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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package cuei_test
import (
"fmt"
"github.com/futzu/cuei"
"testing"
)
func ExampleJson2Cue() {
js := `{
"InfoSection": {
"Name": "Splice Info Section",
"TableID": "0xfc",
"SectionSyntaxIndicator": false,
"Private": false,
"Reserved": "0x3",
"SectionLength": 42,
"ProtocolVersion": 0,
"EncryptedPacket": false,
"EncryptionAlgorithm": 0,
"PtsAdjustment": 0,
"CwIndex": "0xff",
"Tier": "0xfff",
"CommandLength": 15,
"CommandType": 5
},
"Command": {
"Name": "Splice Insert",
"CommandType": 5,
"SpliceEventID": 5690,
"OutOfNetworkIndicator": true,
"ProgramSpliceFlag": true,
"TimeSpecifiedFlag": true,
"PTS": 23683.480033
},
"DescriptorLoopLength": 10,
"Descriptors": [
{
"Length": 8,
"Identifier": "CUEI",
"Name": "Avail Descriptor"
}
],
"Crc32": 3608566905
}
`
cue := cuei.Json2Cue(js)
cue.Encode()
cue.Show()
}
func ExampleNewCue() {
data := "/DCtAAAAAAAAAP/wBQb+Tq9DwQCXAixDVUVJCUvhcH+fAR1QQ1IxXzEyMTYyMTE0MDBXQUJDUkFDSEFFTFJBWSEBAQIsQ1VFSQlL4W9/nwEdUENSMV8xMjE2MjExNDAwV0FCQ1JBQ0hBRUxSQVkRAQECGUNVRUkJTBwVf58BClRLUlIxNjA4NEEQAQECHkNVRUkJTBwWf98AA3clYAEKVEtSUjE2MDg0QSABAdHBXYA="
cue := cuei.NewCue()
cue.Decode(data)
cue.Show()
}
func ExampleCue_Decode() {
data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
cue := cuei.NewCue()
cue.Decode(data)
cue.Show()
}
func ExampleCue_Encode() {
data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
cue := cuei.NewCue()
cue.Decode(data)
fmt.Println(cue.Encode())
}
func ExampleCue_Encode2B64() {
data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
cue := cuei.NewCue()
cue.Decode(data)
fmt.Println(cue.Encode2B64())
}
func ExampleCue_Encode2Hex() {
data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
cue := cuei.NewCue()
cue.Decode(data)
fmt.Println(cue.Encode2Hex())
cue.Decode(cue.Encode2Hex())
cue.Show()
}
func ExampleCue_AdjustPts() {
data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q=="
cue := cuei.NewCue()
cue.Decode(data)
cue.Show()
// Change cue.InfoSection.PtsAdjustment and re-encode cue to bytes
cue.AdjustPts(33.333)
cue.Show()
fmt.Println("Was", data)
fmt.Println("Is", cue.Encode2B64())
}
func Test(t *testing.T) {
t.Run("Json2Cue", func(t *testing.T) {
ExampleJson2Cue()
})
t.Run("Cue.Decode()", func(t *testing.T) {
ExampleCue_Decode()
})
t.Run("Cue.AdjustPts()", func(t *testing.T) {
ExampleCue_AdjustPts()
})
t.Run("NewCue", func(t *testing.T) {
ExampleNewCue()
})
t.Run("Cue_Encode", func(t *testing.T) {
ExampleCue_Encode()
})
t.Run("Cue_Encode2B64", func(t *testing.T) {
ExampleCue_Encode2B64()
})
t.Run("Cue_Encode2Hex", func(t *testing.T) {
ExampleCue_Encode2Hex()
})
}