-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Let's say I have an I2C transaction like this one below. Clearly, any of the operations can fail and in this case error should be returned (At least I2c interface allows this). To simulate such failed operation, I was expecting with_error approach to work (Line 3).
let mut i2c = Mock::new(&[
I2cTransaction::transaction_start(0x76),
I2cTransaction::write(0x76, vec![0x88]), // .with_error(I2cErrorKind::Other),
I2cTransaction::read(0x76, vec![0xCC, 0x6D, 0x1B, 0x68, 0x32, 0x00]),
I2cTransaction::write(0x76, vec![0xA1]),
I2cTransaction::read(0x76, vec![0x4B]),
I2cTransaction::write(0x76, vec![0xE1]),
I2cTransaction::read(0x76, vec![0x70, 0x01, 0x00, 0x13, 0x21, 0x03, 0x1E]),
I2cTransaction::write(0x76, vec![0xFA]),
I2cTransaction::read(0x76, vec![0x7E, 0x9B, 0x00, 0x5D, 0xC2])
.with_error(I2cErrorKind::Other),
I2cTransaction::transaction_end(0x76),
])But it does not and causes panic instead. This panic originates from unwrap on the following line:
https://github.com/dbrgn/embedded-hal-mock/blob/e11348e9d34ef5809eb3b13979bab0efd7d92a44/src/eh1/i2c.rs#L273
For me it seems ? would be more appropriate.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels