don't transmute in test
This commit is contained in:
parent
3ff25d956a
commit
1c22269948
23
src/test.rs
23
src/test.rs
@ -1,4 +1,4 @@
|
||||
use std::{mem, panic};
|
||||
use std::panic;
|
||||
|
||||
use quickcheck::TestResult;
|
||||
|
||||
@ -27,31 +27,30 @@ absv_i2!(__absvdi2: i64);
|
||||
// absv_i2!(__absvti2: i128);
|
||||
|
||||
quickcheck! {
|
||||
fn udivmoddi4(a: (u32, u32), b: (u32, u32)) -> TestResult {
|
||||
let (a, b) = unsafe {
|
||||
(mem::transmute(a), mem::transmute(b))
|
||||
};
|
||||
fn udivmoddi4(n: (u32, u32), d: (u32, u32)) -> TestResult {
|
||||
let n = ::U64 { low: n.0, high: n.1 }[..];
|
||||
let d = ::U64 { low: d.0, high: d.1 }[..];
|
||||
|
||||
if b == 0 {
|
||||
if d == 0 {
|
||||
TestResult::discard()
|
||||
} else {
|
||||
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! {
|
||||
fn udivmodsi4(a: u32, b: u32) -> TestResult {
|
||||
if b == 0 {
|
||||
fn udivmodsi4(n: u32, d: u32) -> TestResult {
|
||||
if d == 0 {
|
||||
TestResult::discard()
|
||||
} else {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user