mirror of https://bitbucket.org/ausocean/av.git
container/mts/mpegts_test.go: added some more interesting test cases for FindPSI
This commit is contained in:
parent
4e43f0f444
commit
0cb9a50af8
|
@ -574,6 +574,32 @@ func TestFindPSI(t *testing.T) {
|
|||
err: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
pkts: []int{media, pat, pmt, media, media},
|
||||
meta: "1",
|
||||
want: want{
|
||||
idx: 188,
|
||||
streamType: gotspsi.PmtStreamTypeMpeg4Video,
|
||||
streamPID: 4,
|
||||
meta: map[string]string{
|
||||
"key": "1",
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
pkts: []int{pat, media, pmt, media, media},
|
||||
meta: "1",
|
||||
want: want{
|
||||
idx: 0,
|
||||
streamType: gotspsi.PmtStreamTypeMpeg4Video,
|
||||
streamPID: 4,
|
||||
meta: map[string]string{
|
||||
"key": "1",
|
||||
},
|
||||
err: ErrNotConsecutive,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var clip bytes.Buffer
|
||||
|
@ -693,35 +719,37 @@ func TestFindPSI(t *testing.T) {
|
|||
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, gotErr, test.want.err)
|
||||
}
|
||||
|
||||
// Check idx
|
||||
if gotIdx != test.want.idx {
|
||||
t.Errorf("did not get expected idx for test %d\nGot: %v\nWant: %v\n", i, gotIdx, test.want.idx)
|
||||
}
|
||||
if gotErr == nil {
|
||||
// Check idx
|
||||
if gotIdx != test.want.idx {
|
||||
t.Errorf("did not get expected idx for test %d\nGot: %v\nWant: %v\n", i, gotIdx, test.want.idx)
|
||||
}
|
||||
|
||||
// Check stream type and PID
|
||||
if gotStreams == nil {
|
||||
t.Fatalf("gotStreams should not be nil")
|
||||
}
|
||||
// Check stream type and PID
|
||||
if gotStreams == nil {
|
||||
t.Fatalf("gotStreams should not be nil")
|
||||
}
|
||||
|
||||
if len(gotStreams) == 0 {
|
||||
t.Fatalf("gotStreams should not be 0 length")
|
||||
}
|
||||
if len(gotStreams) == 0 {
|
||||
t.Fatalf("gotStreams should not be 0 length")
|
||||
}
|
||||
|
||||
s := gotStreams[0]
|
||||
gotStreamType := s.StreamType()
|
||||
gotStreamPID := s.ElementaryPid()
|
||||
s := gotStreams[0]
|
||||
gotStreamType := s.StreamType()
|
||||
gotStreamPID := s.ElementaryPid()
|
||||
|
||||
if gotStreamType != test.want.streamType {
|
||||
t.Errorf("did not get expected stream type for test %d\nGot: %v\nWant: %v\n", i, gotStreamType, test.want.streamType)
|
||||
}
|
||||
if gotStreamType != test.want.streamType {
|
||||
t.Errorf("did not get expected stream type for test %d\nGot: %v\nWant: %v\n", i, gotStreamType, test.want.streamType)
|
||||
}
|
||||
|
||||
if gotStreamPID != test.want.streamPID {
|
||||
t.Errorf("did not get expected stream PID for test %d\nGot: %v\nWant: %v\n", i, gotStreamPID, test.want.streamPID)
|
||||
}
|
||||
if gotStreamPID != test.want.streamPID {
|
||||
t.Errorf("did not get expected stream PID for test %d\nGot: %v\nWant: %v\n", i, gotStreamPID, test.want.streamPID)
|
||||
}
|
||||
|
||||
// Check meta
|
||||
if !reflect.DeepEqual(gotMeta, test.want.meta) {
|
||||
t.Errorf("did not get expected meta for test %d\nGot: %v\nWant: %v\n", i, gotMeta, test.want.meta)
|
||||
// Check meta
|
||||
if !reflect.DeepEqual(gotMeta, test.want.meta) {
|
||||
t.Errorf("did not get expected meta for test %d\nGot: %v\nWant: %v\n", i, gotMeta, test.want.meta)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue