gstreamer: Assert that FromValueOptional works as expected

Fails without the preceding patch.
This commit is contained in:
Jan Alexander Steffens (heftig) 2019-09-24 11:34:08 +02:00 committed by Sebastian Dröge
parent dca2cc1c5d
commit 29710d9970
2 changed files with 25 additions and 0 deletions

View file

@ -474,3 +474,18 @@ lazy_static! {
pub static ref CAPS_FEATURES_MEMORY_SYSTEM_MEMORY: CapsFeatures =
CapsFeatures::new(&[*CAPS_FEATURE_MEMORY_SYSTEM_MEMORY]);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_from_value_optional() {
::init().unwrap();
let a = glib::value::Value::from(None::<&CapsFeatures>);
assert!(a.get::<CapsFeatures>().unwrap().is_none());
let b = glib::value::Value::from(&CapsFeatures::new_empty());
assert!(b.get::<CapsFeatures>().unwrap().is_some());
}
}

View file

@ -837,4 +837,14 @@ mod tests {
assert_eq!(a, s.to_string());
}
#[test]
fn test_from_value_optional() {
::init().unwrap();
let a = glib::value::Value::from(None::<&Structure>);
assert!(a.get::<Structure>().unwrap().is_none());
let b = glib::value::Value::from(&Structure::from_string(&"foo").unwrap());
assert!(b.get::<Structure>().unwrap().is_some());
}
}