Skip to content

Commit

Permalink
30DaysOfTests: ffi:time returns correct time
Browse files Browse the repository at this point in the history
  • Loading branch information
conradkleinespel committed Aug 28, 2017
1 parent 6beec14 commit 148b70c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ffi.rs
Expand Up @@ -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.