something is wrong with the function coverage..
Some checks failed
Rust/spacepackets/pipeline/head There was a failure building this commit
Some checks failed
Rust/spacepackets/pipeline/head There was a failure building this commit
This commit is contained in:
parent
3650507715
commit
38f5e3ba5f
@ -248,6 +248,8 @@ mod tests {
|
||||
use crate::cfdp::pdu::tests::{TEST_DEST_ID, TEST_SEQ_NUM, TEST_SRC_ID};
|
||||
use crate::cfdp::pdu::{CommonPduConfig, PduHeader};
|
||||
use crate::cfdp::{Direction, SegmentMetadataFlag, SegmentationControl, TransmissionMode};
|
||||
#[cfg(feature = "serde")]
|
||||
use postcard::{from_bytes, to_allocvec};
|
||||
|
||||
#[test]
|
||||
fn test_basic() {
|
||||
@ -445,4 +447,39 @@ mod tests {
|
||||
let fd_pdu_read_back = fd_pdu_read_back.unwrap();
|
||||
assert_eq!(fd_pdu_read_back, fd_pdu);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_serialization() {
|
||||
let common_conf =
|
||||
CommonPduConfig::new_with_byte_fields(TEST_SRC_ID, TEST_DEST_ID, TEST_SEQ_NUM).unwrap();
|
||||
let pdu_header = PduHeader::new_for_file_data_default(common_conf, 0);
|
||||
let file_data: [u8; 4] = [1, 2, 3, 4];
|
||||
let fd_pdu = FileDataPdu::new_no_seg_metadata(pdu_header, 10, &file_data);
|
||||
let output = to_allocvec(&fd_pdu).unwrap();
|
||||
let output_converted_back: FileDataPdu = from_bytes(&output).unwrap();
|
||||
assert_eq!(output_converted_back, fd_pdu);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_serialization_with_seg_metadata() {
|
||||
let common_conf =
|
||||
CommonPduConfig::new_with_byte_fields(TEST_SRC_ID, TEST_DEST_ID, TEST_SEQ_NUM).unwrap();
|
||||
let pdu_header = PduHeader::new_for_file_data(
|
||||
common_conf,
|
||||
0,
|
||||
SegmentMetadataFlag::Present,
|
||||
SegmentationControl::WithRecordBoundaryPreservation,
|
||||
);
|
||||
let file_data: [u8; 4] = [1, 2, 3, 4];
|
||||
let seg_metadata: [u8; 4] = [4, 3, 2, 1];
|
||||
let segment_meta =
|
||||
SegmentMetadata::new(RecordContinuationState::StartAndEnd, Some(&seg_metadata))
|
||||
.unwrap();
|
||||
let fd_pdu = FileDataPdu::new_with_seg_metadata(pdu_header, segment_meta, 10, &file_data);
|
||||
let output = to_allocvec(&fd_pdu).unwrap();
|
||||
let output_converted_back: FileDataPdu = from_bytes(&output).unwrap();
|
||||
assert_eq!(output_converted_back, fd_pdu);
|
||||
}
|
||||
}
|
||||
|
@ -500,4 +500,22 @@ mod tests {
|
||||
fn test_serde_pus_service_id() {
|
||||
generic_serde_test(PusServiceId::Verification);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_ptc() {
|
||||
generic_serde_test(Ptc::AbsoluteTime);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_pfc_unsigned() {
|
||||
generic_serde_test(PfcUnsigned::EightBytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_pfc_real() {
|
||||
generic_serde_test(PfcReal::Double);
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ pub enum TimeWindowType {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[cfg(feature = "serde")]
|
||||
use crate::tests::generic_serde_test;
|
||||
|
||||
#[test]
|
||||
fn test_bool_conv_0() {
|
||||
@ -102,4 +104,22 @@ mod tests {
|
||||
let subservice: Subservice = 22u8.try_into().unwrap();
|
||||
assert_eq!(subservice, Subservice::TcCreateScheduleGroup);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_subservice_id() {
|
||||
generic_serde_test(Subservice::TcEnableScheduling);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_sched_status() {
|
||||
generic_serde_test(SchedStatus::Enabled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serde_time_window_type() {
|
||||
generic_serde_test(TimeWindowType::SelectAll);
|
||||
}
|
||||
}
|
||||
|
@ -882,6 +882,8 @@ mod tests {
|
||||
use crate::{CcsdsPacket, SequenceFlags};
|
||||
use alloc::string::ToString;
|
||||
use alloc::vec::Vec;
|
||||
#[cfg(feature = "serde")]
|
||||
use postcard::{from_bytes, to_allocvec};
|
||||
|
||||
fn base_ping_tc_full_ctor() -> PusTcCreator<'static> {
|
||||
let mut sph = SpHeader::tc_unseg(0x02, 0x34, 0).unwrap();
|
||||
@ -1258,4 +1260,13 @@ mod tests {
|
||||
panic!("unexpected error {error}")
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_serialization_tc_serde() {
|
||||
let pus_tc = base_ping_tc_simple_ctor();
|
||||
let output = to_allocvec(&pus_tc).unwrap();
|
||||
let output_converted_back: PusTcCreator = from_bytes(&output).unwrap();
|
||||
assert_eq!(output_converted_back, pus_tc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user