-
Notifications
You must be signed in to change notification settings - Fork 4
/
types_test.go
55 lines (40 loc) · 1.27 KB
/
types_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
package yami
import "testing"
func TestGetFirstVideoTrack(t *testing.T) {
t0 := &Track{Type: TrackGeneral, StreamSize: 0}
t1 := &Track{Type: TrackAudio, StreamSize: 1}
t2 := &Track{Type: TrackVideo, StreamSize: 2}
t3 := &Track{Type: TrackVideo, StreamSize: 3}
m := &MediaInfo{&Media{Tracks: []*Track{t0, t1, t2, t3}}}
if m.GetFirstVideoTrack().StreamSize != t2.StreamSize {
t.Error("Incorrectly determined first VideoTrack")
}
}
func TestGetFirstAudioTrack(t *testing.T) {
t0 := &Track{Type: TrackGeneral, StreamSize: 0}
t1 := &Track{Type: TrackVideo, StreamSize: 1}
t2 := &Track{Type: TrackAudio, StreamSize: 2}
t3 := &Track{Type: TrackVideo, StreamSize: 3}
m := &MediaInfo{&Media{Tracks: []*Track{t0, t1, t2, t3}}}
if m.GetFirstAudioTrack().StreamSize != t2.StreamSize {
t.Error("Incorrectly determined first AudioTrack")
}
}
func TestGetTracksByType(t *testing.T) {
m := &MediaInfo{&Media{Tracks: []*Track{
{Type: TrackGeneral},
{Type: TrackVideo},
{Type: TrackAudio},
{Type: TrackVideo},
{Type: TrackVideo},
}}}
tracks := m.GetTracksByType(TrackVideo)
if len(tracks) != 3 {
t.Error("Unexpected number of returned tracks")
}
for _, track := range tracks {
if track.Type != TrackVideo {
t.Error("Incorrectly determined track type")
}
}
}