gstreamer: Add a test for various combinations of element_error! string formatting

This commit is contained in:
Sebastian Dröge 2023-02-13 11:39:52 +02:00
parent 6f06a26327
commit 60ad9b5038

View file

@ -1406,4 +1406,24 @@ mod tests {
assert_eq!(receiver.recv(), Ok(()));
}
#[test]
fn test_element_error() {
crate::init().unwrap();
let identity = crate::ElementFactory::make("identity").build().unwrap();
crate::element_error!(identity, crate::CoreError::Failed, ("msg"), ["debug"]);
crate::element_error!(identity, crate::CoreError::Failed, ["debug"]);
crate::element_error!(identity, crate::CoreError::Failed, ("msg"));
// We define a new variable for each call so there would be a compiler warning if the
// string formatting did not actually use it.
let x = 123i32;
crate::element_error!(identity, crate::CoreError::Failed, ("msg {x}"), ["debug"]);
let x = 123i32;
crate::element_error!(identity, crate::CoreError::Failed, ["debug {x}"]);
let x = 123i32;
crate::element_error!(identity, crate::CoreError::Failed, ("msg {}", x));
}
}