From 9eaf34931856dd4b0d791b228b47cee98dd8a4fe Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 28 Jan 2022 16:12:16 +0100 Subject: [PATCH] Add tests --- reader_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/reader_test.go b/reader_test.go index 8d60b16c..8bfed863 100644 --- a/reader_test.go +++ b/reader_test.go @@ -972,6 +972,40 @@ func TestDecodeMediaPlaylistStartTime(t *testing.T) { } } +func TestDecodeMasterChannels(t *testing.T) { + f, err := os.Open("sample-playlists/master-with-channels.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]") + } + + alt1 := pp.Variants[0].Alternatives[1] + if alt1.Type != "AUDIO" { + t.Error("Expected AUDIO track in test input Alternatives[1]") + } + + if alt1.Channels != 6 { + t.Error("Expected 6 channels track in test input Alternatives[1]") + } +} + /**************** * Benchmarks * ****************/