From f8df397593255376d8d64255b1ff7f76eb7a19b5 Mon Sep 17 00:00:00 2001 From: koba-e964 <3303362+koba-e964@users.noreply.github.com> Date: Tue, 2 May 2023 11:44:43 +0900 Subject: [PATCH] Fix tests in src/convolution.rs --- src/convolution.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/convolution.rs b/src/convolution.rs index 1251955..4d18e13 100644 --- a/src/convolution.rs +++ b/src/convolution.rs @@ -276,7 +276,7 @@ mod tests { modulus!(M1, M2); fn test(rng: &mut ThreadRng) { - let mut gen_values = |n| gen_values::(rng, n); + let mut gen_values = |n| gen_values::(rng, n); for (n, m) in (1..20).flat_map(|i| (1..20).map(move |j| (i, j))) { let (a, b) = (gen_values(n), gen_values(m)); assert_eq!(conv_naive(&a, &b), super::convolution(&a, &b)); @@ -326,7 +326,7 @@ mod tests { fn simple_raw() where - T: TryFrom + Copy + RemEuclidU32, + T: TryFrom + Copy + RemEuclidU32 + Eq, T::Error: fmt::Debug, { const M1: u32 = 998_244_353; @@ -336,16 +336,21 @@ mod tests { fn test(rng: &mut ThreadRng) where - T: TryFrom + Copy + RemEuclidU32, + T: TryFrom + Copy + RemEuclidU32 + Eq, T::Error: fmt::Debug, M: Modulus, { - let mut gen_raw_values = |n| gen_raw_values::(rng, n); + let mut gen_raw_values = |n| { + gen_raw_values::(rng, n) + .into_iter() + .map(|x| x.try_into().unwrap()) + .collect::>() + }; for (n, m) in (1..20).flat_map(|i| (1..20).map(move |j| (i, j))) { let (a, b) = (gen_raw_values(n), gen_raw_values(m)); - assert_eq!( - conv_raw_naive::<_, M>(&a, &b), - super::convolution_raw::<_, M>(&a, &b), + assert!( + conv_raw_naive::(&a, &b) == super::convolution_raw::(&a, &b), + "values don't match", ); } }