diff options
| author | kennytm <kennytm@gmail.com> | 2019-03-16 14:56:48 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2019-03-16 22:40:19 +0800 |
| commit | d84e063506537637388a0e4f84d74df4599534e8 (patch) | |
| tree | 6b34d7576111e5de3d759f395670f5b7e7099787 | |
| parent | bbe5f3d08b780940bf9c8c25cadc6a377e3258a5 (diff) | |
| parent | adbd0a66457159ffcdd02ee0b553581298968847 (diff) | |
| download | rust-d84e063506537637388a0e4f84d74df4599534e8.tar.gz rust-d84e063506537637388a0e4f84d74df4599534e8.zip | |
Rollup merge of #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
| -rw-r--r-- | src/libstd/time.rs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 6d7093ac33e..4c86f70ad87 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -712,13 +712,6 @@ mod tests { assert_almost_eq!(a - second + second, a); assert_almost_eq!(a.checked_sub(second).unwrap().checked_add(second).unwrap(), a); - // A difference of 80 and 800 years cannot fit inside a 32-bit time_t - if !(cfg!(unix) && crate::mem::size_of::<libc::time_t>() <= 4) { - let eighty_years = second * 60 * 60 * 24 * 365 * 80; - assert_almost_eq!(a - eighty_years + eighty_years, a); - assert_almost_eq!(a - (eighty_years * 10) + (eighty_years * 10), a); - } - let one_second_from_epoch = UNIX_EPOCH + Duration::new(1, 0); let one_second_from_epoch2 = UNIX_EPOCH + Duration::new(0, 500_000_000) + Duration::new(0, 500_000_000); @@ -747,8 +740,8 @@ mod tests { #[test] fn since_epoch() { let ts = SystemTime::now(); - let a = ts.duration_since(UNIX_EPOCH).unwrap(); - let b = ts.duration_since(UNIX_EPOCH - Duration::new(1, 0)).unwrap(); + let a = ts.duration_since(UNIX_EPOCH + Duration::new(1, 0)).unwrap(); + let b = ts.duration_since(UNIX_EPOCH).unwrap(); assert!(b > a); assert_eq!(b - a, Duration::new(1, 0)); |
