Creates a machine backed by `MockPins` pre-seeded with `reads` and returns both the machine and a handle to inspect the trace afterwards.
(reads: &[(u8, bool)])
| 504 | /// Creates a machine backed by `MockPins` pre-seeded with `reads` and returns both the machine |
| 505 | /// and a handle to inspect the trace afterwards. |
| 506 | fn make_mock_machine(reads: &[(u8, bool)]) -> (crate::Machine, Rc<RefCell<MockPins>>) { |
| 507 | let mock_pins = Rc::new(RefCell::new(MockPins::default())); |
| 508 | for &(pin, high) in reads { |
| 509 | mock_pins.borrow_mut().inject_read(Pin(pin), high); |
| 510 | } |
| 511 | let pins: Rc<RefCell<dyn Pins>> = mock_pins.clone(); |
| 512 | let machine = MachineBuilder::default().with_gpio_pins(pins).build(); |
| 513 | (machine, mock_pins) |
| 514 | } |
| 515 | |
| 516 | /// Runs `code` in a machine backed by MockPins pre-seeded with `reads` and asserts that the |
| 517 | /// resulting trace equals `expected_trace`. |
no test coverage detected