mirror of https://github.com/eldruin/ds323x-rs
Put construction tests together
parent
dee3deb073
commit
55bbf9098a
|
@ -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);
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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]) ]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue