Skip to content

Commit

Permalink
tests: Patch missed coverage spots. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer authored Apr 5, 2024
1 parent 00cb074 commit 337aaf4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ mod tests {
fn test_display() {
let t = Timestamp::from(1335020400);
assert_eq!(format!("{:.02}", t), "1335020400.00");
assert_eq!(format!("{}", t), "1335020400");
}
}
6 changes: 6 additions & 0 deletions src/integers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,10 @@ mod tests {
assert_eq!(ts.seconds, 1335020400 - 86400);
assert_eq!(ts.nanos, 500_000_000);
}

#[test]
fn test_rem() {
let ts = Timestamp::new(86500, 12);
assert_eq!(ts % 86400, Timestamp::new(100, 12))
}
}
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl Timestamp {
/// ## Panic
///
/// Panics if the system clock is set to a time prior to the Unix epoch (January 1, 1970).
#[cfg(not(tarpaulin_include))]
pub fn now() -> Self {
let now_dur = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
Expand Down Expand Up @@ -146,6 +147,13 @@ mod tests {

use super::*;

#[test]
fn test_new_overflow() {
let ts = Timestamp::new(1, 1_500_000_000);
check!(ts.seconds() == 2);
check!(ts.subsec(3) == 500);
}

#[test]
fn test_cmp() {
check!(Timestamp::from(1335020400) < Timestamp::from(1335024000));
Expand Down

0 comments on commit 337aaf4

Please sign in to comment.