Coverage Update #47
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user