Skip to content

Commit

Permalink
improved coverage a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Dec 3, 2023
1 parent 4faf1c9 commit 175315e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/ecss/tc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,22 @@ mod tests {

#[test]
fn test_reader_buf_too_small() {
let small_buf: [u8; 5] = [0; 5];
let error = PusTcReader::new(&small_buf);
// if let PusError::RawDataTooShort()
let app_data = &[1, 2, 3, 4];
let pus_tc = base_ping_tc_simple_ctor_with_app_data(app_data);
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}")
}
}
}

0 comments on commit 175315e

Please sign in to comment.