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

47 lines
1.1 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 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(),
2019-09-15 09:25:41 +00:00
&"http://media.example.com/entire1.ts".parse().unwrap()
2019-09-15 08:40:45 +00:00
);
assert_eq!(
media_playlist.segments()[1].uri(),
2019-09-15 09:25:41 +00:00
&"http://media.example.com/entire2.ts".parse().unwrap()
2019-09-15 08:40:45 +00:00
);
}