Skip to content

Commit 7fd2464

Browse files
committed
tests
1 parent b9e7ba0 commit 7fd2464

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

testcrate/tests/big.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn widen_i128() {
2424
#[test]
2525
fn widen_mul_u128() {
2626
let tests = [
27-
(u128::MAX / 2, 2_u128, u256([u64::MAX, u64::MAX, 0, 0])),
27+
(u128::MAX / 2, 2_u128, u256([u64::MAX - 1, u64::MAX, 0, 0])),
2828
(u128::MAX, 2_u128, u256([u64::MAX - 1, u64::MAX, 1, 0])),
2929
(u128::MAX, u128::MAX, u256([1, 0, u64::MAX - 1, u64::MAX])),
3030
(u128::MIN, u128::MIN, u256::ZERO),
@@ -33,15 +33,15 @@ fn widen_mul_u128() {
3333
];
3434

3535
let mut errors = Vec::new();
36-
for (a, b, exp) in tests {
36+
for (i, (a, b, exp)) in tests.iter().enumerate() {
3737
let res = a.zero_widen_mul(b);
3838
if res != exp {
39-
errors.push((a, b, exp, res));
39+
errors.push((i, a, b, exp, res));
4040
}
4141
}
4242

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

6868
let mut errors = Vec::new();
69-
for (a, b, exp) in tests {
69+
for (i, (a, b, exp)) in tests.iter().enumerate() {
7070
let res = a.zero_widen_mul(b);
7171
if res != exp {
72-
errors.push((a, b, exp, res));
72+
errors.push((i, a, b, exp, res));
7373
}
7474
}
7575

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

0 commit comments

Comments
 (0)