Skip to content

Commit d24843d

Browse files
test(math_test_utils): add unit tests for is_quad_residue_mod_prime
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f19a52c commit d24843d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

vm/src/tests/cairo_test_suite/test_math/math_test_utils.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,21 @@ pub fn is_quad_residue_mod_prime(a: &BigUint) -> i64 {
1818
Err(_) => -1,
1919
}
2020
}
21+
22+
#[cfg(test)]
23+
mod tests {
24+
use super::*;
25+
26+
/// Returns 1 for a known quadratic residue: 4 = 2² mod CAIRO_PRIME.
27+
#[test]
28+
fn is_quad_residue_mod_prime_returns_1_for_residue() {
29+
assert_eq!(is_quad_residue_mod_prime(&BigUint::from(4u32)), 1);
30+
}
31+
32+
/// Returns 0 for a known non-residue: 3 is not a square mod CAIRO_PRIME.
33+
#[test]
34+
fn is_quad_residue_mod_prime_returns_0_for_non_residue() {
35+
assert_eq!(is_quad_residue_mod_prime(&BigUint::from(3u32)), 0);
36+
}
37+
38+
}

0 commit comments

Comments
 (0)