Skip to content

Commit

Permalink
Add a test for TimePoint from_secs panic
Browse files Browse the repository at this point in the history
method should panic with to big seconds value
  • Loading branch information
gwen-lg committed Jul 10, 2024
1 parent fcbb5fe commit ef061aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/time/time_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,11 @@ mod tests {
const TIME: f64 = 624.87;
assert_eq!(TimePoint::from_secs(TIME).secs(), 624);
}

#[test]
fn to_big_seconds() {
const TIME: f64 = 9_223_372_036_854_775.808; // i64::MAX + 1 as f64 / 1000
let result = std::panic::catch_unwind(|| TimePoint::from_secs(TIME));
assert!(result.is_err());
}
}

0 comments on commit ef061aa

Please sign in to comment.