[−][src]Module embedded_hal_mock::pin
Mock digital InputPin
and OutputPin
implementations
use std::io::ErrorKind; use embedded_hal_mock::MockError; use embedded_hal_mock::pin::{Transaction as PinTransaction, Mock as PinMock, State as PinState}; use embedded_hal::digital::v2::{InputPin, OutputPin}; let err = MockError::Io(ErrorKind::NotConnected); // Configure expectations let expectations = [ PinTransaction::get(PinState::High), PinTransaction::get(PinState::High), PinTransaction::set(PinState::Low), PinTransaction::set(PinState::High).with_error(err.clone()), ]; // Create pin let mut pin = PinMock::new(&expectations); // Run and test assert_eq!(pin.is_high().unwrap(), true); assert_eq!(pin.is_low().unwrap(), false); pin.set_low().unwrap(); pin.set_high().expect_err("expected error return"); pin.done(); // Update expectations pin.expect(&[]); // ... pin.done();
Structs
Transaction | MockPin transaction |
Enums
State | Digital pin value enumeration |
TransactionKind | MockPin transaction kind, either Get or Set with the associated State |
Type Definitions
Mock | Mock Pin implementation |