Skip to content

Commit 0110b9a

Browse files
committed
Use pointer comparison in test
1 parent 7b6717d commit 0110b9a

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

tests/pass-dep/shims/libc-misc.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ fn test_posix_gettimeofday() {
214214
}
215215

216216
fn test_localtime_r() {
217-
use std::env;
218217
use std::ffi::CStr;
218+
use std::{env, ptr};
219219

220220
// Set timezone to GMT.
221221
let key = "TZ";
@@ -250,22 +250,8 @@ fn test_localtime_r() {
250250
assert_eq!(tm.tm_gmtoff, 0);
251251
unsafe { assert_eq!(CStr::from_ptr(tm.tm_zone).to_str().unwrap(), "+00") };
252252

253-
let res_tm: libc::tm;
254-
unsafe {
255-
res_tm = *res;
256-
}
257-
// The returned value should match the pointer passed in.
258-
assert_eq!(res_tm.tm_sec, 56);
259-
assert_eq!(res_tm.tm_min, 43);
260-
assert_eq!(res_tm.tm_hour, 7);
261-
assert_eq!(res_tm.tm_mday, 7);
262-
assert_eq!(res_tm.tm_mon, 3);
263-
assert_eq!(res_tm.tm_year, 124);
264-
assert_eq!(res_tm.tm_wday, 0);
265-
assert_eq!(res_tm.tm_yday, 97);
266-
assert_eq!(res_tm.tm_isdst, -1);
267-
assert_eq!(res_tm.tm_gmtoff, 0);
268-
unsafe { assert_eq!(CStr::from_ptr(res_tm.tm_zone).to_str().unwrap(), "+00") };
253+
// The returned value is the pointer passed in.
254+
assert!(ptr::eq(res, &mut tm));
269255

270256
//Remove timezone setting.
271257
env::remove_var(key);

0 commit comments

Comments
 (0)