Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
megaadam committed Jan 28, 2022
1 parent f630d00 commit 7358650
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,64 @@ func TestDecodeMediaPlaylistStartTime(t *testing.T) {
}
}

func TestDecodeMasterChannels(t *testing.T) {
f, err := os.Open("sample-playlists/from-apple/master.m3u8")
if err != nil {
t.Fatal(err)
}
p, listType, err := DecodeFrom(bufio.NewReader(f), true)
if err != nil {
t.Fatal(err)
}

if listType != MASTER {
t.Error("Input not recognized as master playlist.")
}
pp := p.(*MasterPlaylist)

alt0 := pp.Variants[0].Alternatives[0]
if alt0.Type != "AUDIO" {
t.Error("Expected AUDIO track in test input Alternatives[0]")
}

if alt0.Channels != 2 {
t.Error("Expected 2 channels track in test input Alternatives[0]")
}

alt2 := pp.Variants[0].Alternatives[2]
if alt2.Type != "AUDIO" {
t.Error("Expected AUDIO track in test input Alternatives[2]")
}

if alt2.Channels != 6 {
t.Error("Expected 6 channels track in test input Alternatives[2]")
}
}

func TestDecodeMediaPlaylistLong(t *testing.T) {
f, err := os.Open("sample-playlists/media-playlist-long.m3u8")
if err != nil {
t.Fatal(err)
}
p, listType, err := DecodeFrom(bufio.NewReader(f), true)
if err != nil {
t.Fatal(err)
}
pp := p.(*MediaPlaylist)
CheckType(t, pp)

if listType != MEDIA {
t.Error("Input not recognized as media playlist.")
}

if len(pp.Segments) < 4000 {
t.Error("Decoded Segments too short")
}
if pp.Segments[3999].URI != "subdir-0-1/1999.ts" {
t.Error("Decoded Segments[3999] contains unexpected data")
}
}

/****************
* Benchmarks *
****************/
Expand Down

0 comments on commit 7358650

Please sign in to comment.