Put construction tests together

pull/4/head
Diego Barrios Romero 2018-11-16 19:32:33 +01:00
parent dee3deb073
commit 55bbf9098a
4 changed files with 17 additions and 27 deletions

View File

@ -0,0 +1,17 @@
mod common;
use common::{ new_ds3231, destroy_ds3231, new_ds3232, destroy_ds3232,
new_ds3234, destroy_ds3234 };
macro_rules! construction_test {
($name:ident, $create:ident, $destroy:ident) => {
#[test]
fn $name() {
let dev = $create(&[]);
$destroy(dev);
}
};
}
construction_test!(can_create_ds3231, new_ds3231, destroy_ds3231);
construction_test!(can_create_ds3232, new_ds3232, destroy_ds3232);
construction_test!(can_create_ds3234, new_ds3234, destroy_ds3234);

View File

@ -1,10 +0,0 @@
extern crate embedded_hal_mock as hal;
extern crate ds323x;
use ds323x::Ds323x;
#[test]
fn can_create_and_destroy() {
let dev = Ds323x::new_ds3231(hal::i2c::Mock::new(&[]));
let mut i2c = dev.destroy_ds3231();
i2c.done();
}

View File

@ -1,10 +0,0 @@
extern crate embedded_hal_mock as hal;
extern crate ds323x;
use ds323x::Ds323x;
#[test]
fn can_create_and_destroy() {
let dev = Ds323x::new_ds3232(hal::i2c::Mock::new(&[]));
let mut i2c = dev.destroy_ds3232();
i2c.done();
}

View File

@ -1,17 +1,10 @@
extern crate embedded_hal_mock as hal;
use hal::spi::Transaction as SpiTrans;
extern crate ds323x;
#[allow(unused)]
mod common;
use common::{ new_ds3234, destroy_ds3234, Register, BitFlags };
#[test]
fn can_create_and_destroy_ds3234() {
let dev = new_ds3234(&[]);
destroy_ds3234(dev);
}
call_test!(can_en_temp_conv_bat, enable_temperature_conversions_on_battery, new_ds3234, destroy_ds3234,
[ SpiTrans::write(vec![Register::TEMP_CONV + 0x80, 0]) ]);