Conversation
ryankurte
left a comment
There was a problem hiding this comment.
thanks for opening this! a few bits of feedback but overall seems good
|
|
||
| impl Transaction { | ||
| /// Create a Transmit transaction | ||
| pub fn transmit(expected_frame: MockFrame) -> Transaction { |
There was a problem hiding this comment.
i think it probably makes sense to constify everywhere possible to make it easier to construct test vectors?
| &t.expected_frame.unwrap(), | ||
| frame, | ||
| "can::transmit data does not match expectation" | ||
| ); |
There was a problem hiding this comment.
this looks pretty reasonable to me, tho i think is missing a path to return errors? (if expected_error is set this value should be returned instead of Ok(()) (and the same for receive and the nb impls)
| } | ||
| } | ||
|
|
||
| impl embedded_can::Error for MockError { |
There was a problem hiding this comment.
i suspect MockError is going to need to reflect the variants in embedded_can::ErrorKind so mocks can deal with at least contention (Bit) and CRC errors... but we can probably expand on this later.
| #[derive(Clone, Debug, PartialEq, Eq)] | ||
| pub struct Transaction { | ||
| expected_mode: Mode, | ||
| expected_frame: Option<MockFrame>, |
There was a problem hiding this comment.
because it's either rx or tx there's only one frame (unlike SPI where you have both incoming and outgoing data) so it seems like expected_frame and response_frame could just be frame?
This is a initial draft for adding a CAN mock. Any feedback would be greatly appreciated.