Add test for state_of_health parser
use nom::{IResult, be_u32, be_u8};
-#[derive(Debug)]
+#[derive(Debug, PartialEq)]
pub struct StateOfHealth {
reset_count: u32, // (4 byte integer) Current epoch reset count, starts at 0, incremented for each power system reset, persistent over the life of the mission
current_time: u32, // (4 byte integer) Current time (seconds) from start of most recent reset
@@ -46,3 +46,30 @@ impl StateOfHealth {
))
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::StateOfHealth;
+ #[test]
+ fn it_parses() {
+ assert_eq!(
+ Ok((
+ b"extra" as &[u8],
+ StateOfHealth {
+ reset_count: 1,
+ current_time: 2,
+ current_rssi: 3,
+ connection_status: 4,
+ globalstar_gateway: 5,
+ last_contact_time: 6,
+ last_attempt_time: 7,
+ call_attempts_since_reset: 8,
+ successful_connects_since_reset: 9,
+ average_connection_duration: 10,
+ connection_duration_std_dev: 11,
+ }
+ )),
+ StateOfHealth::parse(b"\x00\x00\x00\x01\x00\x00\x00\x02\x03\x04\x05\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\x09\x00\x00\x00\x0a\x00\x00\x00\x0bextra")
+ )
+ }
+}
