Skip to content

Commit 1c22269

Browse files
author
Jorge Aparicio
committed
don't transmute in test
1 parent 3ff25d9 commit 1c22269

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/test.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{mem, panic};
1+
use std::panic;
22

33
use quickcheck::TestResult;
44

@@ -27,31 +27,30 @@ absv_i2!(__absvdi2: i64);
2727
// absv_i2!(__absvti2: i128);
2828

2929
quickcheck! {
30-
fn udivmoddi4(a: (u32, u32), b: (u32, u32)) -> TestResult {
31-
let (a, b) = unsafe {
32-
(mem::transmute(a), mem::transmute(b))
33-
};
30+
fn udivmoddi4(n: (u32, u32), d: (u32, u32)) -> TestResult {
31+
let n = ::U64 { low: n.0, high: n.1 }[..];
32+
let d = ::U64 { low: d.0, high: d.1 }[..];
3433

35-
if b == 0 {
34+
if d == 0 {
3635
TestResult::discard()
3736
} else {
3837
let mut r = 0;
39-
let q = ::div::__udivmoddi4(a, b, Some(&mut r));
38+
let q = ::div::__udivmoddi4(n, d, Some(&mut r));
4039

41-
TestResult::from_bool(q * b + r == a)
40+
TestResult::from_bool(q * d + r == n)
4241
}
4342
}
4443
}
4544

4645
quickcheck! {
47-
fn udivmodsi4(a: u32, b: u32) -> TestResult {
48-
if b == 0 {
46+
fn udivmodsi4(n: u32, d: u32) -> TestResult {
47+
if d == 0 {
4948
TestResult::discard()
5049
} else {
5150
let mut r = 0;
52-
let q = ::div::__udivmodsi4(a, b, Some(&mut r));
51+
let q = ::div::__udivmodsi4(n, d, Some(&mut r));
5352

54-
TestResult::from_bool(q * b + r == a)
53+
TestResult::from_bool(q * d + r == n)
5554
}
5655
}
5756
}

0 commit comments

Comments
 (0)