Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
9names committed Apr 14, 2024
1 parent 537c04e commit 01d87ed
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 57 deletions.
8 changes: 4 additions & 4 deletions wii-ext/tests/classic_hd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ macro_rules! assert_joystick_hd {
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();
classic.enable_hires(&mut delay).unwrap();
let input = classic.read_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
classic.enable_hires().unwrap();
let input = classic.read_blocking().unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
Expand Down
30 changes: 15 additions & 15 deletions wii-ext/tests/classic_pdp_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ fn classic_idle() {
];

let mut i2c = i2c::Mock::new(&expectations);
let mut delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), &mut delay).unwrap();
let report = classic.read_report_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let report = classic.read_report_blocking().unwrap();
assert_digital_eq(report, ClassicReading::default());
i2c.done();
}
Expand Down Expand Up @@ -99,9 +99,9 @@ macro_rules! assert_button_fn {
Transaction::read(EXT_I2C_ADDR as u8, $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_report_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_report_blocking().unwrap();
assert_digital_eq(input, ClassicReading {
$x: true,
..Default::default()
Expand Down Expand Up @@ -146,9 +146,9 @@ fn classic_calibrated_idle() {
Transaction::read(EXT_I2C_ADDR as u8, test_data::PDP_LINK_IDLE.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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();
assert_eq!(input.joystick_left_x, 0);
assert_eq!(input.joystick_left_y, 0);
assert_eq!(input.joystick_right_x, 0);
Expand All @@ -173,9 +173,9 @@ fn classic_calibrated_joy_left() {
Transaction::read(EXT_I2C_ADDR as u8, test_data::PDP_LINK_LJOY_L.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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();

assert!(
(i8::MIN..-AXIS_MAX).contains(&input.joystick_left_x),
Expand Down Expand Up @@ -236,9 +236,9 @@ macro_rules! assert_joysticks {
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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
Expand Down
8 changes: 4 additions & 4 deletions wii-ext/tests/classic_pdp_clone_hd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ macro_rules! assert_joystick_hd {
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();
classic.enable_hires(&mut delay).unwrap();
let input = classic.read_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
classic.enable_hires().unwrap();
let input = classic.read_blocking().unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
Expand Down
30 changes: 15 additions & 15 deletions wii-ext/tests/classic_pro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ fn classic_idle() {
];

let mut i2c = i2c::Mock::new(&expectations);
let mut delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), &mut delay).unwrap();
let report = classic.read_report_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let report = classic.read_report_blocking().unwrap();
assert_digital_eq(report, ClassicReading::default());
i2c.done();
}
Expand Down Expand Up @@ -99,9 +99,9 @@ macro_rules! assert_button_fn {
Transaction::read(EXT_I2C_ADDR as u8, $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_report_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_report_blocking().unwrap();
assert_digital_eq(input, ClassicReading {
$x: true,
..Default::default()
Expand Down Expand Up @@ -146,9 +146,9 @@ fn classic_calibrated_idle() {
Transaction::read(EXT_I2C_ADDR as u8, test_data::PRO_IDLE.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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();
assert_eq!(input.joystick_left_x, 0);
assert_eq!(input.joystick_left_y, 0);
assert_eq!(input.joystick_right_x, 0);
Expand All @@ -173,9 +173,9 @@ fn classic_calibrated_joy_left() {
Transaction::read(EXT_I2C_ADDR as u8, test_data::PRO_LJOY_L.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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();

assert!(
(i8::MIN..-AXIS_MAX).contains(&input.joystick_left_x),
Expand Down Expand Up @@ -237,9 +237,9 @@ macro_rules! assert_joysticks {
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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
Expand Down
8 changes: 4 additions & 4 deletions wii-ext/tests/classic_pro_hd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ macro_rules! assert_joystick_hd {
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();
classic.enable_hires(&mut delay).unwrap();
let input = classic.read_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
classic.enable_hires().unwrap();
let input = classic.read_blocking().unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
Expand Down
30 changes: 15 additions & 15 deletions wii-ext/tests/classic_regular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ fn classic_idle() {
];

let mut i2c = i2c::Mock::new(&expectations);
let mut delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), &mut delay).unwrap();
let report = classic.read_report_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let report = classic.read_report_blocking().unwrap();
assert_digital_eq(report, ClassicReading::default());
i2c.done();
}
Expand Down Expand Up @@ -97,9 +97,9 @@ macro_rules! assert_button_fn {
Transaction::read(EXT_I2C_ADDR as u8, $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_report_blocking(&mut delay).unwrap();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_report_blocking().unwrap();
assert_digital_eq(input, ClassicReading {
$x: true,
..Default::default()
Expand Down Expand Up @@ -144,9 +144,9 @@ fn classic_calibrated_idle() {
Transaction::read(EXT_I2C_ADDR as u8, test_data::CLASSIC_IDLE.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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();
assert_eq!(input.joystick_left_x, 0);
assert_eq!(input.joystick_left_y, 0);
assert_eq!(input.joystick_right_x, 0);
Expand Down Expand Up @@ -174,9 +174,9 @@ fn classic_calibrated_joy_left() {
Transaction::read(EXT_I2C_ADDR as u8, test_data::CLASSIC_LJOY_L.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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();

assert!(
(i8::MIN..=-AXIS_MAX).contains(&input.joystick_left_x),
Expand Down Expand Up @@ -237,9 +237,9 @@ macro_rules! assert_joysticks {
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();
let delay = NoopDelay::new();
let mut classic = Classic::new(i2c.clone(), delay).unwrap();
let input = classic.read_blocking().unwrap();

assert!(
($lxl..=$lxh).contains(&input.joystick_left_x),
Expand Down

0 comments on commit 01d87ed

Please sign in to comment.