Skip to content

Commit

Permalink
enable specifying a custom number of iterations for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagician committed Jan 27, 2024
1 parent bf96a5b commit 27cace7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions test-templates/src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ macro_rules! __test_field {

#[macro_export]
macro_rules! test_field {
($mod_name: ident; $field: ty $(; $tail:tt)*) => {
($mod_name:ident; $field:ty; $iterations:expr $(; $tail:tt)*) => {
mod $mod_name {
use super::*;
use ark_ff::{
Expand All @@ -537,9 +537,13 @@ macro_rules! test_field {
};
use ark_serialize::{buffer_bit_byte_size, Flags};
use ark_std::{io::Cursor, rand::Rng, vec::Vec, test_rng, vec, Zero, One, UniformRand};
const ITERATIONS: usize = 1000;
const ITERATIONS: usize = $iterations;

$crate::__test_field!($field $(; $tail)*);
}
};

($mod_name:ident; $field:ty $(; $tail:tt)*) => {
$crate::test_field!($mod_name; $field; 1000 $(; $tail)*);
};
}
8 changes: 6 additions & 2 deletions test-templates/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,20 @@ macro_rules! __test_group {

#[macro_export]
macro_rules! test_group {
($mod_name: ident; $group: ty $(; $tail:tt)*) => {
($mod_name:ident; $group:ty; $iterations:expr $(; $tail:tt)*) => {
mod $mod_name {
use super::*;
use ark_ff::*;
use ark_ec::{PrimeGroup, CurveGroup, ScalarMul, AffineRepr, CurveConfig, short_weierstrass::SWCurveConfig, twisted_edwards::TECurveConfig, scalar_mul::{*, wnaf::*}};
use ark_serialize::*;
use ark_std::{io::Cursor, rand::Rng, vec::Vec, test_rng, vec, Zero, One, UniformRand};
const ITERATIONS: usize = 500;
const ITERATIONS: usize = $iterations;

$crate::__test_group!($group $(; $tail)*);
}
};

($mod_name:ident; $group:ty $(; $tail:tt)*) => {
$crate::test_group!($mod_name; $group; 500 $(; $tail)*);
};
}

0 comments on commit 27cace7

Please sign in to comment.