small test for TC reader invalid input
Some checks failed
Rust/spacepackets/pipeline/head There was a failure building this commit

This commit is contained in:
2023-12-05 15:31:00 +01:00
parent c6c80edb84
commit 4945ea804d
2 changed files with 19 additions and 0 deletions

View File

@ -1233,4 +1233,22 @@ mod tests {
panic!("unexpected error {error}")
}
}
#[test]
fn test_reader_input_too_small() {
let buf: [u8; 5] = [0; 5];
let error = PusTcReader::new(&buf);
assert!(error.is_err());
let error = error.unwrap_err();
if let PusError::ByteConversion(ByteConversionError::FromSliceTooSmall {
found,
expected,
}) = error
{
assert_eq!(found, 5);
assert_eq!(expected, PUS_TC_MIN_LEN_WITHOUT_APP_DATA);
} else {
panic!("unexpected error {error}")
}
}
}