Skip to content

Commit 986c25f

Browse files
msdriggpitdicker
authored andcommitted
Add test_duration_const()
1 parent c76e4bb commit 986c25f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/duration.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,4 +807,38 @@ mod tests {
807807
Err(OutOfRangeError(()))
808808
);
809809
}
810+
811+
#[test]
812+
fn test_duration_const() {
813+
const ONE_WEEK: Duration = Duration::weeks(1);
814+
const ONE_DAY: Duration = Duration::days(1);
815+
const ONE_HOUR: Duration = Duration::hours(1);
816+
const ONE_MINUTE: Duration = Duration::minutes(1);
817+
const ONE_SECOND: Duration = Duration::seconds(1);
818+
const ONE_MILLI: Duration = Duration::milliseconds(1);
819+
const ONE_MICRO: Duration = Duration::microseconds(1);
820+
const ONE_NANO: Duration = Duration::nanoseconds(1);
821+
let combo: Duration = ONE_WEEK
822+
+ ONE_DAY
823+
+ ONE_HOUR
824+
+ ONE_MINUTE
825+
+ ONE_SECOND
826+
+ ONE_MILLI
827+
+ ONE_MICRO
828+
+ ONE_NANO;
829+
830+
assert!(ONE_WEEK != Duration::zero());
831+
assert!(ONE_DAY != Duration::zero());
832+
assert!(ONE_HOUR != Duration::zero());
833+
assert!(ONE_MINUTE != Duration::zero());
834+
assert!(ONE_SECOND != Duration::zero());
835+
assert!(ONE_MILLI != Duration::zero());
836+
assert!(ONE_MICRO != Duration::zero());
837+
assert!(ONE_NANO != Duration::zero());
838+
assert_eq!(
839+
combo,
840+
Duration::seconds(86400 * 7 + 86400 + 3600 + 60 + 1)
841+
+ Duration::nanoseconds(1 + 1_000 + 1_000_000)
842+
);
843+
}
810844
}

0 commit comments

Comments
 (0)