Skip to content

Commit

Permalink
small test for TC reader invalid input
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Dec 5, 2023
1 parent c6c80ed commit 4945ea8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
`PusError::ByteConversionError` variant.
- Ranamed `TlvLvError::ByteConversionError` to `TlvLvError::ByteConversion`.
- Renamed `PusError::IncorrectCrc` to `PusError::ChecksumFailure`.
- Some more struct variant changes for error enumerations.

## Removed

Expand Down
18 changes: 18 additions & 0 deletions src/ecss/tc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
}
}

0 comments on commit 4945ea8

Please sign in to comment.