From ab1221e175f2da577c7a3fb510b5ae5cf41b0697 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Sat, 30 Mar 2019 13:25:47 +0200 Subject: Extract macro --- tests/common/mod.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'tests/common') diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 509dbd8..ae3236c 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -82,12 +82,25 @@ macro_rules! impl_new_destroy { }; } -impl_new_destroy!(Ads1013, new_ads1013, destroy_ads1013, ic::Resolution12Bit, I2cTrans, interface::I2cInterface); -impl_new_destroy!(Ads1113, new_ads1113, destroy_ads1113, ic::Resolution16Bit, I2cTrans, interface::I2cInterface); -impl_new_destroy!(Ads1014, new_ads1014, destroy_ads1014, ic::Resolution12Bit, I2cTrans, interface::I2cInterface); -impl_new_destroy!(Ads1114, new_ads1114, destroy_ads1114, ic::Resolution16Bit, I2cTrans, interface::I2cInterface); -impl_new_destroy!(Ads1015, new_ads1015, destroy_ads1015, ic::Resolution12Bit, I2cTrans, interface::I2cInterface); -impl_new_destroy!(Ads1115, new_ads1115, destroy_ads1115, ic::Resolution16Bit, I2cTrans, interface::I2cInterface); +macro_rules! impl_new_destroy_i2c { + ($ic:ident, $create:ident, $destroy:ident, $conv:ty) => { + impl_new_destroy!( + $ic, + $create, + $destroy, + $conv, + I2cTrans, + interface::I2cInterface + ); + }; +} + +impl_new_destroy_i2c!(Ads1013, new_ads1013, destroy_ads1013, ic::Resolution12Bit); +impl_new_destroy_i2c!(Ads1113, new_ads1113, destroy_ads1113, ic::Resolution16Bit); +impl_new_destroy_i2c!(Ads1014, new_ads1014, destroy_ads1014, ic::Resolution12Bit); +impl_new_destroy_i2c!(Ads1114, new_ads1114, destroy_ads1114, ic::Resolution16Bit); +impl_new_destroy_i2c!(Ads1015, new_ads1015, destroy_ads1015, ic::Resolution12Bit); +impl_new_destroy_i2c!(Ads1115, new_ads1115, destroy_ads1115, ic::Resolution16Bit); #[macro_export] macro_rules! assert_would_block { -- cgit v1.2.3-54-g00ecf