From e151ee75f8c839c27a99e18151c3826f414964a6 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 10 Jan 2020 18:41:04 +0530 Subject: [PATCH] gstreamer: error: add tests --- gstreamer/src/error.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gstreamer/src/error.rs b/gstreamer/src/error.rs index 520b2a631..ebde9eec0 100644 --- a/gstreamer/src/error.rs +++ b/gstreamer/src/error.rs @@ -197,3 +197,33 @@ impl Error for LoggableError { self.bool_error.message.as_ref() } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn error_message() { + let e = ErrorMessage::new( + &::CoreError::Failed, + Some("message"), + Some("debug"), + "filename", + "function", + 7, + ); + assert_eq!( + format!("{}", e), + "Error Some(\"message\") (Some(\"debug\")) at filename:7" + ); + } + + #[test] + fn logabble_error() { + let e: LoggableError = glib::BoolError::new("msg", "filename", "function", 7).into(); + assert_eq!( + format!("{}", e), + "Error \"GST_RUST\": \"msg\" at filename:7" + ); + } +}