well this is annoying work
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
This commit is contained in:
parent
834d56c9bd
commit
da201a91e5
@ -29,3 +29,33 @@ pub enum Subservice {
|
||||
TcGenerateOneShotDiag = 28,
|
||||
TcModifyDiagCollectionInterval = 32,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn test_try_from_u8() {
|
||||
let hk_report_subservice_raw = 25;
|
||||
let hk_report: Subservice = Subservice::try_from(hk_report_subservice_raw).unwrap();
|
||||
assert_eq!(hk_report, Subservice::TmHkPacket);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_into_u8() {
|
||||
let hk_report_raw: u8 = Subservice::TmHkPacket.into();
|
||||
assert_eq!(hk_report_raw, 25);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_partial_eq() {
|
||||
let hk_report_raw = Subservice::TmHkPacket;
|
||||
assert_ne!(hk_report_raw, Subservice::TcGenerateOneShotHk);
|
||||
assert_eq!(hk_report_raw, Subservice::TmHkPacket);
|
||||
}
|
||||
#[test]
|
||||
fn test_copy_clone() {
|
||||
let hk_report = Subservice::TmHkPacket;
|
||||
let hk_report_copy = hk_report;
|
||||
assert_eq!(hk_report, hk_report_copy);
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ pub enum PusServiceId {
|
||||
/// All PUS versions. Only PUS C is supported by this library.
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[non_exhaustive]
|
||||
pub enum PusVersion {
|
||||
EsaPus = 0,
|
||||
PusA = 1,
|
||||
@ -95,8 +96,9 @@ impl TryFrom<u8> for PusVersion {
|
||||
}
|
||||
|
||||
/// ECSS Packet Type Codes (PTC)s.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[repr(u8)]
|
||||
pub enum PacketTypeCodes {
|
||||
Boolean = 1,
|
||||
Enumerated = 2,
|
||||
@ -115,8 +117,9 @@ pub enum PacketTypeCodes {
|
||||
pub type Ptc = PacketTypeCodes;
|
||||
|
||||
/// ECSS Packet Field Codes (PFC)s for the unsigned [Ptc].
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[repr(u8)]
|
||||
pub enum UnsignedPfc {
|
||||
OneByte = 4,
|
||||
TwelveBits = 8,
|
||||
@ -131,8 +134,9 @@ pub enum UnsignedPfc {
|
||||
}
|
||||
|
||||
/// ECSS Packet Field Codes (PFC)s for the real (floating point) [Ptc].
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[repr(u8)]
|
||||
pub enum RealPfc {
|
||||
/// 4 octets simple precision format (IEEE)
|
||||
Float = 1,
|
||||
@ -376,9 +380,13 @@ pub trait WritablePusPacket {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use alloc::string::ToString;
|
||||
|
||||
use crate::ecss::{EcssEnumU16, EcssEnumU32, EcssEnumU8, UnsignedEnum};
|
||||
use crate::ByteConversionError;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_enum_u8() {
|
||||
let mut buf = [0, 0, 0];
|
||||
@ -448,4 +456,25 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pus_error_display() {
|
||||
let unsupport_version = PusError::VersionNotSupported(super::PusVersion::EsaPus);
|
||||
let write_str = unsupport_version.to_string();
|
||||
assert_eq!(write_str, "PUS version EsaPus not supported")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_service_id_from_u8() {
|
||||
let verification_id_raw = 1;
|
||||
let verification_id = PusServiceId::try_from(verification_id_raw).unwrap();
|
||||
assert_eq!(verification_id, PusServiceId::Verification);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ptc_from_u8() {
|
||||
let ptc_raw = Ptc::AbsoluteTime as u8;
|
||||
let ptc = Ptc::try_from(ptc_raw).unwrap();
|
||||
assert_eq!(ptc, Ptc::AbsoluteTime);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user