From 49ea4e45fa52573687eaf2ee20728e156176caec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 12 Jul 2017 10:38:34 +0300 Subject: [PATCH] Re-enable iterator test for Structure --- gstreamer/src/caps.rs | 2 +- gstreamer/src/structure.rs | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 24a113154..cecae34f8 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -12,7 +12,6 @@ use structure::*; use glib; use ffi; -use glib::ToValue; use glib::translate::{from_glib, from_glib_none, from_glib_full, ToGlibPtr}; #[repr(C)] @@ -225,6 +224,7 @@ unsafe impl Send for CapsRef {} #[cfg(test)] mod tests { use super::*; + use glib::ToValue; #[test] fn test_simple() { diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 542d55080..07791dfa5 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -457,27 +457,24 @@ mod tests { assert_eq!(s.get::("f3").unwrap(), 123i32); assert_eq!(s.fields().collect::>(), vec!["f1", "f2", "f3"]); - /* - assert_eq!( - s.iter() - .map(|(f, v)| (f, v.clone())) - .collect::>(), - vec![ - ("f1", "abc".into()), - ("f2","bcd".into()), - ("f3", 123i32.into()), - ] - ); + + let v = s.iter().map(|(f, v)| (f, v.clone())).collect::>(); + assert_eq!(v.len(), 3); + assert_eq!(v[0].0, "f1"); + assert_eq!(v[0].1.get::<&str>().unwrap(), "abc"); + assert_eq!(v[1].0, "f2"); + assert_eq!(v[1].1.get::<&str>().unwrap(), "bcd"); + assert_eq!(v[2].0, "f3"); + assert_eq!(v[2].1.get::().unwrap(), 123i32); let s2 = Structure::new( "test", &[ - ("f1", "abc".into()), - ("f2", "bcd".into()), - ("f3", 123i32.into()), + ("f1", &"abc".to_value()), + ("f2", &"bcd".to_value()), + ("f3", &123i32.to_value()), ], ); assert_eq!(s, s2); -*/ } }