also added a unittest
This commit is contained in:
parent
fd893fbf89
commit
a3da71668f
@ -22,8 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
classes. The old `PusTm` class is deprecated now.
|
||||
- Implement `Display` and `Error` for `StdTimestampError` properly.
|
||||
- Remove some redundant `Error` suffixes for enum error variants.
|
||||
- `CommonPduConfig`: `new_with_defaults` replaced by `new_with_byte_fields`
|
||||
and `new_with_defaults` has now empty argument list.
|
||||
- `CommonPduConfig`: `new_with_defaults` replaced by `new_with_byte_fields`.
|
||||
|
||||
## Added
|
||||
|
||||
@ -33,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Added new marker trait `IsPusTelecommand` implemented by `PusTcCreator` and `PusTcReader`.
|
||||
- `metadata_param` getter method for the `MetadataPdu` object.
|
||||
- `Default` impl for CFDP `ChecksumType`
|
||||
- `Default` impl for CFDP `CommonPduConfig`
|
||||
|
||||
## Fixed
|
||||
|
||||
|
@ -220,10 +220,20 @@ impl CommonPduConfig {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn source_id(&self) -> UnsignedByteField {
|
||||
self.source_entity_id
|
||||
}
|
||||
|
||||
pub fn dest_id(&self) -> UnsignedByteField {
|
||||
self.dest_entity_id
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CommonPduConfig {
|
||||
/// The defaults for the source ID, destination ID and the transaction sequence number is the
|
||||
/// [UnsignedByteFieldU8] with an intitial value of 0
|
||||
pub fn new_with_defaults() -> Self {
|
||||
// new can not fail for these input parameters
|
||||
fn default() -> Self {
|
||||
// The new function can not fail for these input parameters.
|
||||
Self::new(
|
||||
UnsignedByteFieldU8::new(0),
|
||||
UnsignedByteFieldU8::new(0),
|
||||
@ -235,14 +245,6 @@ impl CommonPduConfig {
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn source_id(&self) -> UnsignedByteField {
|
||||
self.source_entity_id
|
||||
}
|
||||
|
||||
pub fn dest_id(&self) -> UnsignedByteField {
|
||||
self.dest_entity_id
|
||||
}
|
||||
}
|
||||
|
||||
pub const FIXED_HEADER_LEN: usize = 4;
|
||||
@ -683,6 +685,18 @@ mod tests {
|
||||
assert_eq!(pdu_header.header_len(), 7);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_basic_state_default() {
|
||||
let default_conf = CommonPduConfig::default();
|
||||
assert_eq!(default_conf.source_id(), UnsignedByteFieldU8::new(0).into());
|
||||
assert_eq!(default_conf.dest_id(), UnsignedByteFieldU8::new(0).into());
|
||||
assert_eq!(default_conf.transaction_seq_num, UnsignedByteFieldU8::new(0).into());
|
||||
assert_eq!(default_conf.trans_mode, TransmissionMode::Acknowledged);
|
||||
assert_eq!(default_conf.direction, Direction::TowardsReceiver);
|
||||
assert_eq!(default_conf.crc_flag, CrcFlag::NoCrc);
|
||||
assert_eq!(default_conf.file_flag, LargeFileFlag::Normal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialization_1() {
|
||||
let src_id = UnsignedByteFieldU8::new(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user