Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Apr 16, 2024
1 parent b9e7ba0 commit 7fd2464
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions testcrate/tests/big.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn widen_i128() {
#[test]
fn widen_mul_u128() {
let tests = [
(u128::MAX / 2, 2_u128, u256([u64::MAX, u64::MAX, 0, 0])),
(u128::MAX / 2, 2_u128, u256([u64::MAX - 1, u64::MAX, 0, 0])),
(u128::MAX, 2_u128, u256([u64::MAX - 1, u64::MAX, 1, 0])),
(u128::MAX, u128::MAX, u256([1, 0, u64::MAX - 1, u64::MAX])),
(u128::MIN, u128::MIN, u256::ZERO),
Expand All @@ -33,15 +33,15 @@ fn widen_mul_u128() {
];

let mut errors = Vec::new();
for (a, b, exp) in tests {
for (i, (a, b, exp)) in tests.iter().enumerate() {
let res = a.zero_widen_mul(b);
if res != exp {
errors.push((a, b, exp, res));
errors.push((i, a, b, exp, res));
}
}

for (a, b, exp, res) in &errors {
eprintln!("FAILURE: {a:#036x} * {b:#036x} = {exp:#036x} got {res:#036x}");
for (i, a, b, exp, res) in &errors {
eprintln!("FAILURE ({i}): {a:#034x} * {b:#034x} = {exp:x} got {res:x}");
}
assert!(errors.is_empty());
}
Expand All @@ -66,15 +66,15 @@ fn widen_mul_i128() {
];

let mut errors = Vec::new();
for (a, b, exp) in tests {
for (i, (a, b, exp)) in tests.iter().enumerate() {
let res = a.zero_widen_mul(b);
if res != exp {
errors.push((a, b, exp, res));
errors.push((i, a, b, exp, res));
}
}

for (a, b, exp, res) in &errors {
eprintln!("FAILURE: {a:#036x} * {b:#036x} = {exp:#036x} got {res:#036x}");
for (i, a, b, exp, res) in &errors {
eprintln!("FAILURE ({i}): {a:#034x} * {b:#034x} = {exp:x} got {res:x}");
}
assert!(errors.is_empty());
}

0 comments on commit 7fd2464

Please sign in to comment.