Skip to content

Commit

Permalink
test: modifed the tests in other files in slice_ops directory
Browse files Browse the repository at this point in the history
Signed-off-by: Abinand P <[email protected]>
  • Loading branch information
Abiji-2020 committed Nov 6, 2024
1 parent 2a22e26 commit 524ae0a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
26 changes: 13 additions & 13 deletions crates/proof-of-sql/src/base/slice_ops/inner_product_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::base::scalar::{test_scalar::TestScalar, Curve25519Scalar};
use crate::base::scalar::test_scalar::TestScalar;

#[test]
fn test_inner_product() {
Expand Down Expand Up @@ -36,22 +36,22 @@ fn test_inner_product_scalar_uneven() {
assert_eq!(TestScalar::from(8u64), inner_product(&a, &b));
}

/// test inner product with curve25519scalar
/// test inner product with `TestScalar`
#[test]
fn test_inner_product_curve25519scalar() {
let a = vec![Curve25519Scalar::from(1u64), Curve25519Scalar::from(2u64)];
let b = vec![Curve25519Scalar::from(2u64), Curve25519Scalar::from(3u64)];
assert_eq!(Curve25519Scalar::from(8u64), inner_product(&a, &b));
fn test_inner_product_testscalar() {
let a = vec![TestScalar::from(1u64), TestScalar::from(2u64)];
let b = vec![TestScalar::from(2u64), TestScalar::from(3u64)];
assert_eq!(TestScalar::from(8u64), inner_product(&a, &b));
}

/// test uneven inner product with curve25519scalars
/// test uneven inner product with `TestScalar`
#[test]
fn test_inner_product_curve25519scalar_uneven() {
let a = vec![Curve25519Scalar::from(1u64), Curve25519Scalar::from(2u64)];
fn test_inner_product_testscalar_uneven() {
let a = vec![TestScalar::from(1u64), TestScalar::from(2u64)];
let b = vec![
Curve25519Scalar::from(2u64),
Curve25519Scalar::from(3u64),
Curve25519Scalar::from(4u64),
TestScalar::from(2u64),
TestScalar::from(3u64),
TestScalar::from(4u64),
];
assert_eq!(Curve25519Scalar::from(8u64), inner_product(&a, &b));
assert_eq!(TestScalar::from(8u64), inner_product(&a, &b));
}
8 changes: 4 additions & 4 deletions crates/proof-of-sql/src/base/slice_ops/mul_add_assign_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ fn test_mul_add_assign_uneven_panic() {
mul_add_assign(&mut a, 10, &b);
}

/// test [`mul_add_assign`] with curve25519scalar
/// test [`mul_add_assign`] with `TestScalar`
#[test]
fn test_mul_add_assign_curve25519scalar() {
fn test_mul_add_assign_testscalar() {
let mut a = vec![TestScalar::from(1u64), TestScalar::from(2u64)];
let b = vec![TestScalar::from(2u64), TestScalar::from(3u64)];
mul_add_assign(&mut a, TestScalar::from(10u64), &b);
Expand All @@ -44,9 +44,9 @@ fn test_mul_add_assign_curve25519scalar() {
assert_eq!(a, c);
}

/// test [`mul_add_assign`] with uneven curve25519scalars
/// test [`mul_add_assign`] with uneven `TestScalar`
#[test]
fn test_mul_add_assign_curve25519scalar_uneven() {
fn test_mul_add_assign_testscalar_uneven() {
let mut a = vec![
TestScalar::from(1u64),
TestScalar::from(2u64),
Expand Down
16 changes: 8 additions & 8 deletions crates/proof-of-sql/src/base/slice_ops/slice_cast_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ fn test_slice_cast_with_random() {
assert_eq!(a, b);
}

/// random test casting from integer to curve25519scalar
/// random test casting from integer to `TestScalar`
#[test]
fn test_slice_cast_with_random_from_integer_to_curve25519scalar() {
fn test_slice_cast_with_random_from_integer_to_testscalar() {
use rand::Rng;
let mut rng = rand::thread_rng();
let a: Vec<u32> = (0..100).map(|_| rng.gen()).collect();
let b: Vec<Curve25519Scalar> = a.iter().map(|&x| Curve25519Scalar::from(x)).collect();
let a: Vec<Curve25519Scalar> = slice_cast_with(&a, |&x| Curve25519Scalar::from(x));
let b: Vec<TestScalar> = a.iter().map(|&x| TestScalar::from(x)).collect();
let a: Vec<TestScalar> = slice_cast_with(&a, |&x| TestScalar::from(x));
assert_eq!(a, b);
}

/// random test auto casting from integer to curve25519scalar
/// random test auto casting from integer to `TestScalar`
#[test]
fn test_slice_cast_random_from_integer_to_curve25519scalar() {
fn test_slice_cast_random_from_integer_to_testscalar() {
use rand::Rng;
let mut rng = rand::thread_rng();
let a: Vec<u32> = (0..100).map(|_| rng.gen()).collect();
let b: Vec<Curve25519Scalar> = a.iter().map(|&x| Curve25519Scalar::from(x)).collect();
let a: Vec<Curve25519Scalar> = slice_cast(&a);
let b: Vec<TestScalar> = a.iter().map(|&x| TestScalar::from(x)).collect();
let a: Vec<TestScalar> = slice_cast(&a);
assert_eq!(a, b);
}

Expand Down

0 comments on commit 524ae0a

Please sign in to comment.