Permalink
Browse files

30DaysOfTests: ffi:time returns correct time

  • Loading branch information...
conradkdotcom committed Aug 28, 2017
1 parent 6beec14 commit 148b70c601a8c8bc67a34ccbbfabddfdf55fc362
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/ffi.rs
View
@@ -27,9 +27,21 @@ mod internal {
pub fn time() -> time_t {
let retrieved_time = unsafe { internal::time(ptr::null_mut()) };
if retrieved_time == (!0 as u32) {
if retrieved_time == !(0 as u32) {
panic!("Could not get time from system");
}
retrieved_time
}
#[cfg(test)]
mod test {
use ffi::time;
#[test]
fn test_time() {
let t_2030 = 1893456000;
let t = time();
assert!(t > 0 && t < t_2030);
}
}

0 comments on commit 148b70c

Please sign in to comment.