video: Add test cases for enum to_string

This commit is contained in:
Marijn Suijten 2020-11-18 22:47:50 +01:00
parent 040772ab61
commit a7348023a0

View file

@ -455,6 +455,31 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test]
fn enum_to_string() {
gst::init().unwrap();
assert_eq!(&format!("{}", crate::VideoFormat::Argb), "ARGB");
assert_eq!(&format!("{:?}", crate::VideoFormat::Argb), "Argb");
assert_eq!(crate::VideoFormat::Argb.to_str(), "ARGB");
assert_eq!(&format!("{}", crate::VideoFormat::Unknown), "UNKNOWN");
assert_eq!(&format!("{:?}", crate::VideoFormat::Unknown), "Unknown");
assert_eq!(crate::VideoFormat::Unknown.to_str(), "UNKNOWN");
assert_eq!(
&format!("{:?}", crate::VideoFormat::__Unknown(-1)),
"__Unknown(-1)"
);
}
#[test]
#[should_panic]
fn enum_to_string_panics() {
assert_eq!(&format!("{}", crate::VideoFormat::__Unknown(-1)), "UNKNOWN");
assert_eq!(crate::VideoFormat::__Unknown(-1).to_str(), "UNKNOWN");
}
#[test] #[test]
fn test_display() { fn test_display() {
gst::init().unwrap(); gst::init().unwrap();