Skip to content

Commit

Permalink
Cargo fmt again
Browse files Browse the repository at this point in the history
  • Loading branch information
9names committed Apr 9, 2024
1 parent 117873b commit 1ab9cc3
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 126 deletions.
126 changes: 63 additions & 63 deletions wii-ext/tests/classic_pro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,71 +221,71 @@ macro_rules! assert_joysticks {
$rtl:expr, $rth:expr
) => {
paste! {
#[test]
fn [<test_calibrated_ $y:lower>]() {
let expectations = vec![
// Reset controller
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
// Init
Transaction::write(EXT_I2C_ADDR as u8, vec![240, 85]),
Transaction::write(EXT_I2C_ADDR as u8, vec![251, 0]),
// Calibration read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$x.to_vec()),
// Input read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$y.to_vec()),
];
let mut i2c = i2c::Mock::new(&expectations);
let mut delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), &mut delay).unwrap();
let input = classic.read_blocking(&mut delay).unwrap();
#[test]
fn [<test_calibrated_ $y:lower>]() {
let expectations = vec![
// Reset controller
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
// Init
Transaction::write(EXT_I2C_ADDR as u8, vec![240, 85]),
Transaction::write(EXT_I2C_ADDR as u8, vec![251, 0]),
// Calibration read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$x.to_vec()),
// Input read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$y.to_vec()),
];
let mut i2c = i2c::Mock::new(&expectations);
let mut delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), &mut delay).unwrap();
let input = classic.read_blocking(&mut delay).unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
"left_x = {}, expected between {} and {}",
input.joystick_left_x,
$lxl,
$lxh
);
assert!(
($lyl..=$lyh).contains(&input.joystick_left_y),
"left_y = {}, expected between {} and {}",
input.joystick_left_y,
$lyl,
$lyh
);
assert!(
($rxl..=$rxh).contains(&input.joystick_right_x),
"right_x = {}, expected between {} and {}",
input.joystick_right_x,
$rxl,
$rxh
);
assert!(
($ryl..=$ryh).contains(&input.joystick_right_y),
"right_y = {}, expected between {} and {}",
input.joystick_right_y,
$ryl,
$ryh
);
assert!(
($ltl..=$lth).contains(&input.trigger_left),
"trigger_left = {}, expected between {} and {}",
input.trigger_left,
$ltl,
$lth
);
assert!(
($rtl..=$rth).contains(&input.trigger_right),
"trigger_right = {}, expected between {} and {}",
input.trigger_right,
$rtl,
$rth
);
i2c.done();
}
assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
"left_x = {}, expected between {} and {}",
input.joystick_left_x,
$lxl,
$lxh
);
assert!(
($lyl..=$lyh).contains(&input.joystick_left_y),
"left_y = {}, expected between {} and {}",
input.joystick_left_y,
$lyl,
$lyh
);
assert!(
($rxl..=$rxh).contains(&input.joystick_right_x),
"right_x = {}, expected between {} and {}",
input.joystick_right_x,
$rxl,
$rxh
);
assert!(
($ryl..=$ryh).contains(&input.joystick_right_y),
"right_y = {}, expected between {} and {}",
input.joystick_right_y,
$ryl,
$ryh
);
assert!(
($ltl..=$lth).contains(&input.trigger_left),
"trigger_left = {}, expected between {} and {}",
input.trigger_left,
$ltl,
$lth
);
assert!(
($rtl..=$rth).contains(&input.trigger_right),
"trigger_right = {}, expected between {} and {}",
input.trigger_right,
$rtl,
$rth
);
i2c.done();
}
}
};
}

Expand Down
126 changes: 63 additions & 63 deletions wii-ext/tests/classic_regular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,71 +221,71 @@ macro_rules! assert_joysticks {
$rtl:expr, $rth:expr
) => {
paste! {
#[test]
fn [<test_calibrated_ $y:lower>]() {
let expectations = vec![
// Reset controller
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
// Init
Transaction::write(EXT_I2C_ADDR as u8, vec![240, 85]),
Transaction::write(EXT_I2C_ADDR as u8, vec![251, 0]),
// Calibration read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$x.to_vec()),
// Input read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$y.to_vec()),
];
let mut i2c = i2c::Mock::new(&expectations);
let mut delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), &mut delay).unwrap();
let input = classic.read_blocking(&mut delay).unwrap();
#[test]
fn [<test_calibrated_ $y:lower>]() {
let expectations = vec![
// Reset controller
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
// Init
Transaction::write(EXT_I2C_ADDR as u8, vec![240, 85]),
Transaction::write(EXT_I2C_ADDR as u8, vec![251, 0]),
// Calibration read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$x.to_vec()),
// Input read
Transaction::write(EXT_I2C_ADDR as u8, vec![0]),
Transaction::read(EXT_I2C_ADDR as u8, test_data::$y.to_vec()),
];
let mut i2c = i2c::Mock::new(&expectations);
let mut delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), &mut delay).unwrap();
let input = classic.read_blocking(&mut delay).unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
"left_x = {}, expected between {} and {}",
input.joystick_left_x,
$lxl,
$lxh
);
assert!(
($lyl..=$lyh).contains(&input.joystick_left_y),
"left_y = {}, expected between {} and {}",
input.joystick_left_y,
$lyl,
$lyh
);
assert!(
($rxl..=$rxh).contains(&input.joystick_right_x),
"right_x = {}, expected between {} and {}",
input.joystick_right_x,
$rxl,
$rxh
);
assert!(
($ryl..=$ryh).contains(&input.joystick_right_y),
"right_y = {}, expected between {} and {}",
input.joystick_right_y,
$ryl,
$ryh
);
assert!(
($ltl..=$lth).contains(&input.trigger_left),
"trigger_left = {}, expected between {} and {}",
input.trigger_left,
$ltl,
$lth
);
assert!(
($rtl..=$rth).contains(&input.trigger_right),
"trigger_right = {}, expected between {} and {}",
input.trigger_right,
$rtl,
$rth
);
i2c.done();
}
assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
"left_x = {}, expected between {} and {}",
input.joystick_left_x,
$lxl,
$lxh
);
assert!(
($lyl..=$lyh).contains(&input.joystick_left_y),
"left_y = {}, expected between {} and {}",
input.joystick_left_y,
$lyl,
$lyh
);
assert!(
($rxl..=$rxh).contains(&input.joystick_right_x),
"right_x = {}, expected between {} and {}",
input.joystick_right_x,
$rxl,
$rxh
);
assert!(
($ryl..=$ryh).contains(&input.joystick_right_y),
"right_y = {}, expected between {} and {}",
input.joystick_right_y,
$ryl,
$ryh
);
assert!(
($ltl..=$lth).contains(&input.trigger_left),
"trigger_left = {}, expected between {} and {}",
input.trigger_left,
$ltl,
$lth
);
assert!(
($rtl..=$rth).contains(&input.trigger_right),
"trigger_right = {}, expected between {} and {}",
input.trigger_right,
$rtl,
$rth
);
i2c.done();
}
}
};
}

Expand Down

0 comments on commit 1ab9cc3

Please sign in to comment.