fixed tests

This commit is contained in:
Nicholas Ward 2021-07-21 14:33:47 -07:00
parent b17dabefeb
commit 292a28e6e3
2 changed files with 11 additions and 9 deletions

View File

@ -132,8 +132,9 @@ impl Field for QuarticCrandallField {
let combined_first = second as u128 * (1u128 << 64) + first as u128;
let combined_second = fourth as u128 * (1u128 << 64) + third as u128;
let combined = BigUint::from(combined_second) * (BigUint::from(1u32) << 128) + combined_first;
let combined =
BigUint::from(combined_second) * (BigUint::from(1u32) << 128) + combined_first;
combined
}

View File

@ -132,7 +132,8 @@ pub fn run_binaryop_test_cases<F, BinaryOp, ExpectedOp>(
.zip(shifted_inputs.clone())
.map(|(x, y)| (x.clone(), y.clone()))
.map(|(x, y)| {
op(F::from_canonical_biguint(x), F::from_canonical_biguint(y)).to_canonical_biguint()
op(F::from_canonical_biguint(x), F::from_canonical_biguint(y))
.to_canonical_biguint()
})
.collect();
@ -165,10 +166,10 @@ macro_rules! test_arithmetic {
fn arithmetic_addition() {
let modulus = <$field>::order();
crate::field::field_testing::run_binaryop_test_cases(
modulus,
modulus.clone(),
WORD_BITS,
<$field>::add,
BigUint::add,
|x, y| (x.clone() + y.clone()) % modulus.clone(),
)
}
@ -210,10 +211,10 @@ macro_rules! test_arithmetic {
fn arithmetic_multiplication() {
let modulus = <$field>::order();
crate::field::field_testing::run_binaryop_test_cases(
modulus,
modulus.clone(),
WORD_BITS,
<$field>::mul,
BigUint::mul,
|x, y| x.clone() * y.clone() % modulus.clone(),
)
}
@ -221,10 +222,10 @@ macro_rules! test_arithmetic {
fn arithmetic_square() {
let modulus = <$field>::order();
crate::field::field_testing::run_unaryop_test_cases(
modulus,
modulus.clone(),
WORD_BITS,
|x: $field| x.square(),
|x| x.clone() * x,
|x| (x.clone() * x.clone()) % modulus.clone(),
)
}