Coverage Update #47

Merged
muellerr merged 35 commits from coverage-update into main 2023-12-06 18:05:57 +01:00
2 changed files with 43 additions and 0 deletions
Showing only changes of commit bf13a432b8 - Show all commits

View File

@ -237,6 +237,9 @@ impl Error for TlvLvError {
#[cfg(test)]
mod tests {
use super::*;
#[cfg(feature = "serde")]
use postcard::{from_bytes, to_allocvec};
#[test]
fn test_crc_from_bool() {
@ -263,4 +266,28 @@ mod tests {
let fault_handler_code = FaultHandlerCode::try_from(fault_handler_code_raw).unwrap();
assert_eq!(fault_handler_code, FaultHandlerCode::NoticeOfSuspension);
}
#[test]
#[cfg(feature="serde")]
fn test_serde_impl_pdu_type() {
let pdu_type = PduType::FileData;
let output = to_allocvec(&pdu_type).unwrap();
assert_eq!(from_bytes::<PduType>(&output).unwrap(), pdu_type);
}
#[test]
#[cfg(feature="serde")]
fn test_serde_impl_direction() {
let direction = Direction::TowardsReceiver;
let output = to_allocvec(&direction).unwrap();
assert_eq!(from_bytes::<Direction>(&output).unwrap(), direction);
}
#[test]
#[cfg(feature="serde")]
fn test_serde_impl_transmission_mode() {
let mode = TransmissionMode::Unacknowledged;
let output = to_allocvec(&mode).unwrap();
assert_eq!(from_bytes::<TransmissionMode>(&output).unwrap(), mode);
}
}

View File

@ -200,6 +200,8 @@ mod tests {
};
use super::*;
#[cfg(feature = "serde")]
use postcard::{from_bytes, to_allocvec};
fn verify_state(ack_pdu: &AckPdu, expected_crc_flag: CrcFlag, expected_dir: Direction) {
assert_eq!(ack_pdu.condition_code(), ConditionCode::NoError);
@ -316,4 +318,18 @@ mod tests {
);
verify_state(&ack_pdu, CrcFlag::WithCrc, Direction::TowardsSender);
}
#[test]
#[cfg(feature="serde")]
fn test_ack_pdu_serialization() {
let pdu_conf = common_pdu_conf(CrcFlag::WithCrc, LargeFileFlag::Normal);
let pdu_header = PduHeader::new_no_file_data(pdu_conf, 0);
let ack_pdu = AckPdu::new_for_eof_pdu(
pdu_header,
ConditionCode::NoError,
TransactionStatus::Active,
);
let output = to_allocvec(&ack_pdu).unwrap();
assert_eq!(from_bytes::<AckPdu>(&output).unwrap(), ack_pdu);
}
}