From ec3a11cec1cb2f1a9687990f1dd7bce8a76a26ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Thu, 8 Aug 2019 16:14:43 +0200 Subject: [PATCH] Fix functions unit tests for v < 1_12 --- gstreamer/src/functions.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gstreamer/src/functions.rs b/gstreamer/src/functions.rs index f9fb399d6..0e615d90e 100644 --- a/gstreamer/src/functions.rs +++ b/gstreamer/src/functions.rs @@ -8,7 +8,6 @@ use glib::translate::*; use gst_sys; -use std::mem; use std::ptr; use Element; @@ -111,6 +110,8 @@ pub fn calculate_linear_regression( xy: &[(u64, u64)], temp: Option<&mut [(u64, u64)]>, ) -> Option<(u64, u64, u64, u64, f64)> { + use std::mem; + unsafe { assert_eq!(mem::size_of::() * 2, mem::size_of::<(u64, u64)>()); assert_eq!(mem::align_of::(), mem::align_of::<(u64, u64)>()); @@ -143,10 +144,14 @@ pub fn calculate_linear_regression( #[cfg(test)] mod tests { - use super::*; - + #[cfg(feature = "v1_12")] #[test] fn test_calculate_linear_regression() { + // Moved the module `use` inside test function because this is the only test for now + // and it is feature-gated, so it generates a warning when the feature is not selected. + // Can be moved out of the function when other tests are added. + use super::*; + ::init().unwrap(); let values = [(0, 0), (1, 1), (2, 2), (3, 3)];