add test for no crc writes
This commit is contained in:
parent
ab93ea46be
commit
e44a3a9d0c
@ -380,7 +380,9 @@ impl WritablePusPacket for PusTcCreator<'_> {
|
||||
PUS_TC_MIN_LEN_WITHOUT_APP_DATA + self.app_data.len()
|
||||
}
|
||||
|
||||
/// Write the raw PUS byte representation to a provided buffer.
|
||||
/// Writes the packet to the given slice without writing the CRC.
|
||||
///
|
||||
/// The returned size is the written size WITHOUT the CRC.
|
||||
fn write_to_bytes_no_crc(&self, slice: &mut [u8]) -> Result<usize, PusError> {
|
||||
let mut curr_idx = 0;
|
||||
let tc_header_len = size_of::<zc::PusTcSecondaryHeader>();
|
||||
@ -679,7 +681,7 @@ mod tests {
|
||||
let mut test_buf: [u8; 32] = [0; 32];
|
||||
let size = pus_tc
|
||||
.write_to_bytes_crc_no_table(test_buf.as_mut_slice())
|
||||
.expect("Error writing TC to buffer");
|
||||
.expect("error writing tc to buffer");
|
||||
assert_eq!(size, 13);
|
||||
assert_eq!(
|
||||
pus_tc.opt_crc16().unwrap(),
|
||||
@ -687,6 +689,18 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialization_no_crc() {
|
||||
let pus_tc = base_ping_tc_simple_ctor();
|
||||
let mut test_buf: [u8; 32] = [0; 32];
|
||||
let size = pus_tc
|
||||
.write_to_bytes_no_crc(test_buf.as_mut_slice())
|
||||
.expect("error writing tc to buffer");
|
||||
assert_eq!(size, 11);
|
||||
assert_eq!(test_buf[11], 0);
|
||||
assert_eq!(test_buf[12], 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deserialization() {
|
||||
let pus_tc = base_ping_tc_simple_ctor();
|
||||
|
@ -977,6 +977,19 @@ mod tests {
|
||||
verify_raw_ping_reply(pus_tm.opt_crc16().unwrap(), &buf);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialization_no_source_data_no_crc() {
|
||||
let timestamp = dummy_timestamp();
|
||||
let pus_tm = base_ping_reply_full_ctor(timestamp);
|
||||
let mut buf: [u8; 32] = [0; 32];
|
||||
let ser_len = pus_tm
|
||||
.write_to_bytes_no_crc(&mut buf)
|
||||
.expect("Serialization failed");
|
||||
assert_eq!(ser_len, 20);
|
||||
assert_eq!(buf[20], 0);
|
||||
assert_eq!(buf[21], 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialization_with_source_data() {
|
||||
let src_data = [1, 2, 3];
|
||||
|
Loading…
x
Reference in New Issue
Block a user