test fixes
This commit is contained in:
parent
39ec3e795c
commit
cb0ddb1338
@ -193,11 +193,11 @@ pub struct InvalidTlvTypeFieldError {
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub enum TlvLvError {
|
||||
#[error("TLV/LV error: {0}")]
|
||||
#[error("{0}")]
|
||||
DataTooLarge(#[from] TlvLvDataTooLargeError),
|
||||
#[error("TLV/LV error: {0}")]
|
||||
#[error("byte conversion error: {0}")]
|
||||
ByteConversion(#[from] ByteConversionError),
|
||||
#[error("TLV/LV error: {0}")]
|
||||
#[error("{0}")]
|
||||
InvalidTlvTypeField(#[from] InvalidTlvTypeFieldError),
|
||||
#[error("invalid value length {0}")]
|
||||
InvalidValueLength(usize),
|
||||
|
@ -780,7 +780,7 @@ pub mod tests {
|
||||
assert_eq!(expected, Some(FileDirectiveType::MetadataPdu));
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"invalid directive type value 255, expected Some(MetadataPdu)"
|
||||
"invalid directive type, found 255, expected Some(MetadataPdu)"
|
||||
);
|
||||
} else {
|
||||
panic!("Expected InvalidDirectiveType error, got {:?}", error);
|
||||
@ -806,7 +806,7 @@ pub mod tests {
|
||||
assert_eq!(expected, FileDirectiveType::MetadataPdu);
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"found directive type EofPdu, expected MetadataPdu"
|
||||
"wrong directive type, found EofPdu, expected MetadataPdu"
|
||||
);
|
||||
} else {
|
||||
panic!("Expected InvalidDirectiveType error, got {:?}", error);
|
||||
|
@ -31,18 +31,18 @@ pub enum FileDirectiveType {
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub enum PduError {
|
||||
#[error("PDU error: {0}")]
|
||||
#[error("byte conversion error: {0}")]
|
||||
ByteConversion(#[from] ByteConversionError),
|
||||
/// Found version ID invalid, not equal to [super::CFDP_VERSION_2].
|
||||
#[error("CFDP version missmatch {0}")]
|
||||
#[error("CFDP version missmatch, found {0}, expected {ver}", ver = super::CFDP_VERSION_2)]
|
||||
CfdpVersionMissmatch(u8),
|
||||
/// Invalid length for the entity ID detected. Only the values 1, 2, 4 and 8 are supported.
|
||||
#[error("invalid entity ID length {0}")]
|
||||
#[error("invalid PDU entity ID length {0}, only [1, 2, 4, 8] are allowed")]
|
||||
InvalidEntityLen(u8),
|
||||
/// Invalid length for the entity ID detected. Only the values 1, 2, 4 and 8 are supported.
|
||||
#[error("invalid transaction ID length {0}")]
|
||||
InvalidTransactionSeqNumLen(u8),
|
||||
#[error("source ID length {src_id_len} and destination ID length {dest_id_len} missmatch")]
|
||||
#[error("missmatch of PDU source ID length {src_id_len} and destination ID length {dest_id_len}")]
|
||||
SourceDestIdLenMissmatch {
|
||||
src_id_len: usize,
|
||||
dest_id_len: usize,
|
||||
@ -61,7 +61,7 @@ pub enum PduError {
|
||||
found: u8,
|
||||
expected: Option<FileDirectiveType>,
|
||||
},
|
||||
#[error("invalid start or end of scope value")]
|
||||
#[error("invalid start or end of scope value for NAK PDU")]
|
||||
InvalidStartOrEndOfScopeValue,
|
||||
/// Invalid condition code. Contains the raw detected value.
|
||||
#[error("invalid condition code {0}")]
|
||||
@ -901,7 +901,7 @@ mod tests {
|
||||
assert_eq!(raw_version, CFDP_VERSION_2 + 1);
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"cfdp version missmatch, found 2, expected 1"
|
||||
"CFDP version missmatch, found 2, expected 1"
|
||||
);
|
||||
} else {
|
||||
panic!("invalid exception: {}", error);
|
||||
@ -949,7 +949,7 @@ mod tests {
|
||||
assert_eq!(expected, 7);
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"source slice with size 6 too small, expected at least 7 bytes"
|
||||
"byte conversion error: source slice with size 6 too small, expected at least 7 bytes"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ mod tests {
|
||||
assert_eq!(dest_id_len, 2);
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"missmatch of PDU source length 1 and destination length 2"
|
||||
"missmatch of PDU source ID length 1 and destination ID length 2"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -751,7 +751,7 @@ mod tests {
|
||||
if let PduError::InvalidStartOrEndOfScopeValue = error {
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"invalid start or end of scope for NAK PDU"
|
||||
"invalid start or end of scope value for NAK PDU"
|
||||
);
|
||||
} else {
|
||||
panic!("unexpected error {error}");
|
||||
|
@ -1043,14 +1043,14 @@ mod tests {
|
||||
let tlv_res = Tlv::new(TlvType::MsgToUser, &buf_too_large);
|
||||
assert!(tlv_res.is_err());
|
||||
let error = tlv_res.unwrap_err();
|
||||
if let TlvLvError::DataTooLarge(data_too_large) = error {
|
||||
assert_eq!(data_too_large.0, u8::MAX as usize + 1);
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"data with size 256 larger than allowed 255 bytes"
|
||||
);
|
||||
} else {
|
||||
panic!("unexpected error {:?}", error);
|
||||
match error {
|
||||
TlvLvDataTooLargeError(size) => {
|
||||
assert_eq!(size, u8::MAX as usize + 1);
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"data with size 256 larger than allowed 255 bytes"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user