1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-11-15 20:01:01 +00:00
hls_m3u8/tests/playlist.rs

42 lines
1.3 KiB
Rust
Raw Normal View History

2019-09-15 08:40:45 +00:00
//! Credits go to
//! - https://github.com/globocom/m3u8/blob/master/tests/playlists.py
use std::time::Duration;
use hls_m3u8::tags::{ExtInf, ExtXEndList};
use hls_m3u8::{MediaPlaylist, MediaSegment};
use pretty_assertions::assert_eq;
2019-09-15 08:40:45 +00:00
#[test]
fn test_simple_playlist() {
2020-02-10 12:20:39 +00:00
let playlist = concat!(
"#EXTM3U\n",
"#EXT-X-TARGETDURATION:5220\n",
"#EXTINF:0,\n",
"http://media.example.com/entire1.ts\n",
"#EXTINF:5220,\n",
"http://media.example.com/entire2.ts\n",
"#EXT-X-ENDLIST\n"
);
2019-09-15 08:40:45 +00:00
assert_eq!(
MediaPlaylist::builder()
.target_duration(Duration::from_secs(5220))
.segments(vec![
MediaSegment::builder()
.inf(ExtInf::new(Duration::from_secs(0)))
.uri("http://media.example.com/entire1.ts")
.build()
.unwrap(),
MediaSegment::builder()
.inf(ExtInf::new(Duration::from_secs(5220)))
.uri("http://media.example.com/entire2.ts")
.build()
.unwrap(),
])
.end_list(ExtXEndList)
.build()
.unwrap(),
playlist.parse::<MediaPlaylist>().unwrap(),
2019-09-15 08:40:45 +00:00
);
}