don't transmute in test

This commit is contained in:
Jorge Aparicio 2016-08-11 01:42:34 -05:00
parent 3ff25d956a
commit 1c22269948
1 changed files with 11 additions and 12 deletions

View File

@ -1,4 +1,4 @@
use std::{mem, panic}; use std::panic;
use quickcheck::TestResult; use quickcheck::TestResult;
@ -27,31 +27,30 @@ absv_i2!(__absvdi2: i64);
// absv_i2!(__absvti2: i128); // absv_i2!(__absvti2: i128);
quickcheck! { quickcheck! {
fn udivmoddi4(a: (u32, u32), b: (u32, u32)) -> TestResult { fn udivmoddi4(n: (u32, u32), d: (u32, u32)) -> TestResult {
let (a, b) = unsafe { let n = ::U64 { low: n.0, high: n.1 }[..];
(mem::transmute(a), mem::transmute(b)) let d = ::U64 { low: d.0, high: d.1 }[..];
};
if b == 0 { if d == 0 {
TestResult::discard() TestResult::discard()
} else { } else {
let mut r = 0; let mut r = 0;
let q = ::div::__udivmoddi4(a, b, Some(&mut r)); let q = ::div::__udivmoddi4(n, d, Some(&mut r));
TestResult::from_bool(q * b + r == a) TestResult::from_bool(q * d + r == n)
} }
} }
} }
quickcheck! { quickcheck! {
fn udivmodsi4(a: u32, b: u32) -> TestResult { fn udivmodsi4(n: u32, d: u32) -> TestResult {
if b == 0 { if d == 0 {
TestResult::discard() TestResult::discard()
} else { } else {
let mut r = 0; let mut r = 0;
let q = ::div::__udivmodsi4(a, b, Some(&mut r)); let q = ::div::__udivmodsi4(n, d, Some(&mut r));
TestResult::from_bool(q * b + r == a) TestResult::from_bool(q * d + r == n)
} }
} }
} }