mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-06-01 19:43:39 +00:00
c53e9e33f1
This will allow for better troubleshooting of failing test, because you don't have to search for the difference (between left and right). This is especially helpful for larger assertions.
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use strum::{Display, EnumString};
|
|
|
|
/// Specifies the media type.
|
|
#[allow(missing_docs)]
|
|
#[derive(Ord, PartialOrd, Display, EnumString, Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
#[strum(serialize_all = "SCREAMING-KEBAB-CASE")]
|
|
pub enum MediaType {
|
|
Audio,
|
|
Video,
|
|
Subtitles,
|
|
ClosedCaptions,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn test_parser() {
|
|
assert_eq!(MediaType::Audio, "AUDIO".parse().unwrap());
|
|
assert_eq!(MediaType::Video, "VIDEO".parse().unwrap());
|
|
assert_eq!(MediaType::Subtitles, "SUBTITLES".parse().unwrap());
|
|
assert_eq!(
|
|
MediaType::ClosedCaptions,
|
|
"CLOSED-CAPTIONS".parse().unwrap()
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn test_display() {
|
|
assert_eq!(MediaType::Audio.to_string(), "AUDIO".to_string());
|
|
assert_eq!(MediaType::Video.to_string(), "VIDEO".to_string());
|
|
assert_eq!(MediaType::Subtitles.to_string(), "SUBTITLES".to_string());
|
|
assert_eq!(
|
|
MediaType::ClosedCaptions.to_string(),
|
|
"CLOSED-CAPTIONS".to_string()
|
|
);
|
|
}
|
|
}
|