about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-09-07 13:09:18 +0800
committerkennytm <kennytm@gmail.com>2017-09-07 17:14:27 +0800
commit83d14bda7fe87b37b61904417cfb53f6351b5f3a (patch)
treeb4bea11c04abd47a8f979ab374850b42492e786b
parent756026563d82f8d339f7d66c4ca5f5974e210f82 (diff)
downloadrust-83d14bda7fe87b37b61904417cfb53f6351b5f3a.tar.gz
rust-83d14bda7fe87b37b61904417cfb53f6351b5f3a.zip
Disable the 80-year-difference test on 32-bit-time_t platforms.
-rw-r--r--src/libstd/time/mod.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs
index 291def3e646..d4993ded843 100644
--- a/src/libstd/time/mod.rs
+++ b/src/libstd/time/mod.rs
@@ -520,9 +520,12 @@ mod tests {
 
         assert_almost_eq!(a - second + second, a);
 
-        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);
+        // A difference of 80 and 800 years cannot fit inside a 32-bit time_t
+        if !(cfg!(unix) && ::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)