Skip to content

Commit adf0927

Browse files
authored
Rollup merge of rust-lang#59147 - jethrogb:jb/time-tests, r=sfackler
Make std time tests more robust for platform differences Previously, `time::tests::since_epoch` and `time::tests::system_time_math` would fail if the platform represents a SystemTime as unix epoch + `u64` nanoseconds. r? @sfackler
2 parents 06c2a0f + adbd0a6 commit adf0927

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/libstd/time.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -712,13 +712,6 @@ mod tests {
712712
assert_almost_eq!(a - second + second, a);
713713
assert_almost_eq!(a.checked_sub(second).unwrap().checked_add(second).unwrap(), a);
714714

715-
// A difference of 80 and 800 years cannot fit inside a 32-bit time_t
716-
if !(cfg!(unix) && crate::mem::size_of::<libc::time_t>() <= 4) {
717-
let eighty_years = second * 60 * 60 * 24 * 365 * 80;
718-
assert_almost_eq!(a - eighty_years + eighty_years, a);
719-
assert_almost_eq!(a - (eighty_years * 10) + (eighty_years * 10), a);
720-
}
721-
722715
let one_second_from_epoch = UNIX_EPOCH + Duration::new(1, 0);
723716
let one_second_from_epoch2 = UNIX_EPOCH + Duration::new(0, 500_000_000)
724717
+ Duration::new(0, 500_000_000);
@@ -747,8 +740,8 @@ mod tests {
747740
#[test]
748741
fn since_epoch() {
749742
let ts = SystemTime::now();
750-
let a = ts.duration_since(UNIX_EPOCH).unwrap();
751-
let b = ts.duration_since(UNIX_EPOCH - Duration::new(1, 0)).unwrap();
743+
let a = ts.duration_since(UNIX_EPOCH + Duration::new(1, 0)).unwrap();
744+
let b = ts.duration_since(UNIX_EPOCH).unwrap();
752745
assert!(b > a);
753746
assert_eq!(b - a, Duration::new(1, 0));
754747

0 commit comments

Comments
 (0)