From 03ac16b5c00eccaef318e2c157b8b6a188262303 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 28 Aug 2024 14:08:19 -0700 Subject: [PATCH] MVPoly: add tests for is_constant --- mvpoly/tests/prime.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mvpoly/tests/prime.rs b/mvpoly/tests/prime.rs index 7c27e49fec..4fc619cfe4 100644 --- a/mvpoly/tests/prime.rs +++ b/mvpoly/tests/prime.rs @@ -663,3 +663,24 @@ fn test_degree_random_degree() { let degree = unsafe { p.degree() }; assert!(degree <= max_degree); } + +#[test] +fn test_is_constant() { + let mut rng = o1_utils::tests::make_test_rng(None); + let c = Fp::rand(&mut rng); + let p = Dense::::from(c); + assert!(p.is_constant()); + + let p = Dense::::zero(); + assert!(p.is_constant()); + + let p = Dense::::from_variable(2_usize); + assert!(!p.is_constant()); + + let p = Dense::::from_variable(3_usize); + assert!(!p.is_constant()); + + // This might be flaky + let p = unsafe { Dense::::random(&mut rng, None) }; + assert!(!p.is_constant()); +}