improved coverage a bit
This commit is contained in:
parent
4faf1c99d8
commit
175315e44e
@ -1205,8 +1205,22 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_reader_buf_too_small() {
|
fn test_reader_buf_too_small() {
|
||||||
let small_buf: [u8; 5] = [0; 5];
|
let app_data = &[1, 2, 3, 4];
|
||||||
let error = PusTcReader::new(&small_buf);
|
let pus_tc = base_ping_tc_simple_ctor_with_app_data(app_data);
|
||||||
// if let PusError::RawDataTooShort()
|
let mut buf = [0; 32];
|
||||||
|
let written_len = pus_tc.write_to_bytes(&mut buf).unwrap();
|
||||||
|
let error = PusTcReader::new(&buf[0..PUS_TC_MIN_LEN_WITHOUT_APP_DATA + 1]);
|
||||||
|
assert!(error.is_err());
|
||||||
|
let error = error.unwrap_err();
|
||||||
|
if let PusError::ByteConversion(ByteConversionError::FromSliceTooSmall {
|
||||||
|
found,
|
||||||
|
expected,
|
||||||
|
}) = error
|
||||||
|
{
|
||||||
|
assert_eq!(found, PUS_TC_MIN_LEN_WITHOUT_APP_DATA + 1);
|
||||||
|
assert_eq!(expected, written_len);
|
||||||
|
} else {
|
||||||
|
panic!("unexpected error {error}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user