added additional tests
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
e081504b33
commit
c59b015a20
@ -996,7 +996,11 @@ fn add_for_max_ccsds_days_val<T: ProvidesDaysLength>(
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
increment_ms_of_day(&mut next_ms_of_day, duration.subsec_millis(), &mut next_ccsds_days);
|
increment_ms_of_day(
|
||||||
|
&mut next_ms_of_day,
|
||||||
|
duration.subsec_millis(),
|
||||||
|
&mut next_ccsds_days,
|
||||||
|
);
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
// The subsecond millisecond were already handled.
|
// The subsecond millisecond were already handled.
|
||||||
|
@ -382,7 +382,12 @@ fn get_new_stamp_after_addition(
|
|||||||
new_subsec_millis -= 1000;
|
new_subsec_millis -= 1000;
|
||||||
increment_seconds(1);
|
increment_seconds(1);
|
||||||
}
|
}
|
||||||
increment_seconds(duration.as_secs().try_into().expect("duration seconds exceeds u32::MAX"));
|
increment_seconds(
|
||||||
|
duration
|
||||||
|
.as_secs()
|
||||||
|
.try_into()
|
||||||
|
.expect("duration seconds exceeds u32::MAX"),
|
||||||
|
);
|
||||||
UnixTimestamp::const_new(new_unix_seconds, new_subsec_millis)
|
UnixTimestamp::const_new(new_unix_seconds, new_subsec_millis)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,6 +539,14 @@ mod tests {
|
|||||||
assert_eq!(stamp1.subsecond_millis().unwrap(), 500);
|
assert_eq!(stamp1.subsecond_millis().unwrap(), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_addition_on_ref() {
|
||||||
|
let stamp0 = &UnixTimestamp::new(20, 500).unwrap();
|
||||||
|
let stamp1 = stamp0 + Duration::from_millis(2500);
|
||||||
|
assert_eq!(stamp1.unix_seconds, 23);
|
||||||
|
assert!(stamp1.subsecond_millis().is_none());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_addition_spillover() {
|
fn test_addition_spillover() {
|
||||||
let mut stamp0 = UnixTimestamp::new(1, 900).unwrap();
|
let mut stamp0 = UnixTimestamp::new(1, 900).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user