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
2019-09-21 12:11:36 +02:00

46 lines
1.1 KiB
Rust

//! Credits go to
//! - https://github.com/globocom/m3u8/blob/master/tests/playlists.py
use hls_m3u8::tags::*;
use hls_m3u8::MediaPlaylist;
use std::time::Duration;
#[test]
fn test_simple_playlist() {
let playlist = r#"
#EXTM3U
#EXT-X-TARGETDURATION:5220
#EXTINF:0,
http://media.example.com/entire1.ts
#EXTINF:5220,
http://media.example.com/entire2.ts
#EXT-X-ENDLIST"#;
let media_playlist = playlist.parse::<MediaPlaylist>().unwrap();
assert_eq!(
media_playlist.target_duration_tag(),
ExtXTargetDuration::new(Duration::from_secs(5220))
);
assert_eq!(media_playlist.segments().len(), 2);
assert_eq!(
media_playlist.segments()[0].inf_tag(),
&ExtInf::new(Duration::from_secs(0))
);
assert_eq!(
media_playlist.segments()[1].inf_tag(),
&ExtInf::new(Duration::from_secs(5220))
);
assert_eq!(
media_playlist.segments()[0].uri(),
&"http://media.example.com/entire1.ts".to_string()
);
assert_eq!(
media_playlist.segments()[1].uri(),
&"http://media.example.com/entire2.ts".to_string()
);
}