From 3cb312f7daa59715497a93ba2888a958fc5cdc4e Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Sat, 30 Mar 2019 13:07:52 +0200 Subject: Extract function --- src/conversion.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/conversion.rs b/src/conversion.rs index 644ed4a..fef80ac 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -83,19 +83,23 @@ mod tests { assert_invalid_input_data::<()>(Ok(0)); } + fn convert_threshold>(value: i16) -> u16 { + T::convert_threshold(value).unwrap() + } + #[test] fn convert_threshold_12_bits() { assert_invalid_input_data::<()>(ic::Resolution12Bit::convert_threshold(2048)); assert_invalid_input_data::<()>(ic::Resolution12Bit::convert_threshold(-2049)); - assert_eq!( 0, >::convert_threshold(0).unwrap()); - assert_eq!(0x7FF0, >::convert_threshold(2047).unwrap()); - assert_eq!(0x8000, >::convert_threshold(-2048).unwrap()); - assert_eq!(0xFFF0, >::convert_threshold(-1).unwrap()); + assert_eq!(0, convert_threshold::(0)); + assert_eq!(0x7FF0, convert_threshold::(2047)); + assert_eq!(0x8000, convert_threshold::(-2048)); + assert_eq!(0xFFF0, convert_threshold::(-1)); } #[test] fn convert_threshold_16_bits() { - assert_eq!(0x7FFF, >::convert_threshold(32767).unwrap()); - assert_eq!(0x8000, >::convert_threshold(-32768).unwrap()); + assert_eq!(0x7FFF, convert_threshold::(32767)); + assert_eq!(0x8000, convert_threshold::(-32768)); } } -- cgit v1.2.3-54-g00ecf