diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/ads1x1x/mode/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/devices/ads1x1x/mode/mod.rs b/src/devices/ads1x1x/mode/mod.rs index 1a01d27..81a5795 100644 --- a/src/devices/ads1x1x/mode/mod.rs +++ b/src/devices/ads1x1x/mode/mod.rs @@ -24,3 +24,24 @@ where mod oneshot; mod continuous; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn convert_12_bits() { + assert_eq!( 0, convert_measurement::<ic::Ads1013>(0)); + assert_eq!( 2047, convert_measurement::<ic::Ads1013>(0x7FFF)); + assert_eq!(-2048, convert_measurement::<ic::Ads1013>(0x8000)); + assert_eq!( -1, convert_measurement::<ic::Ads1013>(0xFFFF)); + } + + #[test] + fn convert_16_bits() { + assert_eq!( 0, convert_measurement::<ic::Ads1113>(0)); + assert_eq!( 32767, convert_measurement::<ic::Ads1113>(0x7FFF)); + assert_eq!(-32768, convert_measurement::<ic::Ads1113>(0x8000)); + assert_eq!( -1, convert_measurement::<ic::Ads1113>(0xFFFF)); + } +} |