Skip to content

Commit 30ed074

Browse files
msdriggpitdicker
authored andcommitted
Add test_duration_const()
1 parent 0995d40 commit 30ed074

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
@@ -797,4 +797,38 @@ mod tests {
797797
Err(OutOfRangeError(()))
798798
);
799799
}
800+
801+
#[test]
802+
fn test_duration_const() {
803+
const ONE_WEEK: Duration = Duration::weeks(1);
804+
const ONE_DAY: Duration = Duration::days(1);
805+
const ONE_HOUR: Duration = Duration::hours(1);
806+
const ONE_MINUTE: Duration = Duration::minutes(1);
807+
const ONE_SECOND: Duration = Duration::seconds(1);
808+
const ONE_MILLI: Duration = Duration::milliseconds(1);
809+
const ONE_MICRO: Duration = Duration::microseconds(1);
810+
const ONE_NANO: Duration = Duration::nanoseconds(1);
811+
let combo: Duration = ONE_WEEK
812+
+ ONE_DAY
813+
+ ONE_HOUR
814+
+ ONE_MINUTE
815+
+ ONE_SECOND
816+
+ ONE_MILLI
817+
+ ONE_MICRO
818+
+ ONE_NANO;
819+
820+
assert!(ONE_WEEK != Duration::zero());
821+
assert!(ONE_DAY != Duration::zero());
822+
assert!(ONE_HOUR != Duration::zero());
823+
assert!(ONE_MINUTE != Duration::zero());
824+
assert!(ONE_SECOND != Duration::zero());
825+
assert!(ONE_MILLI != Duration::zero());
826+
assert!(ONE_MICRO != Duration::zero());
827+
assert!(ONE_NANO != Duration::zero());
828+
assert_eq!(
829+
combo,
830+
Duration::seconds(86400 * 7 + 86400 + 3600 + 60 + 1)
831+
+ Duration::nanoseconds(1 + 1_000 + 1_000_000)
832+
);
833+
}
800834
}

0 commit comments

Comments
 (0)