diff --git a/src/x.rs b/src/x.rs index 9d74ddc11..282395516 100644 --- a/src/x.rs +++ b/src/x.rs @@ -76,3 +76,16 @@ pub use libc::atof; pub unsafe fn atof(nptr: *mut libc::c_char) -> libc::c_double { libc::strtod(nptr, std::ptr::null_mut()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_atox() { + unsafe { + assert_eq!(atol(b"\x00" as *const u8 as *const libc::c_char), 0); + assert_eq!(atoi(b"\x00" as *const u8 as *const libc::c_char), 0); + } + } +} diff --git a/tests/stress.rs b/tests/stress.rs index 3e3112304..655710075 100644 --- a/tests/stress.rs +++ b/tests/stress.rs @@ -544,30 +544,6 @@ unsafe fn stress_functions(context: &dc_context_t) { } else { }; free(mime_0 as *mut libc::c_void); - if 0 != !(atol(b"\x00" as *const u8 as *const libc::c_char) == 0i32 as libc::c_long) - as libc::c_int as libc::c_long - { - __assert_rtn( - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) - .as_ptr(), - b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char, - 370i32, - b"atol(\"\")==0\x00" as *const u8 as *const libc::c_char, - ); - } else { - }; - if 0 != !(atoi(b"\x00" as *const u8 as *const libc::c_char) == 0i32) as libc::c_int - as libc::c_long - { - __assert_rtn( - (*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00")) - .as_ptr(), - b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char, - 371i32, - b"atoi(\"\")==0\x00" as *const u8 as *const libc::c_char, - ); - } else { - }; let f: libc::c_double = dc_atof(b"1.23\x00" as *const u8 as *const libc::c_char); if 0 != !(f > 1.22f64 && f < 1.24f64) as libc::c_int as libc::c_long { __assert_rtn(