Skip to content

Commit 52b99c0

Browse files
committed
Add a specific test for corner cases of lucas_test()
1 parent 50d8ea8 commit 52b99c0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/hazmat/lucas.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,22 @@ mod tests {
812812
}
813813
}
814814

815+
#[test]
816+
fn corner_cases() {
817+
// Test 1 and 2 specifically
818+
819+
// By convention, 1 is composite. That's what `num-prime` returns.
820+
let res = lucas_test(&U64::ONE, BruteForceBase, LucasCheck::AlmostExtraStrong);
821+
assert_eq!(res, Primality::Composite);
822+
823+
let res = lucas_test(
824+
&U64::from(2u32),
825+
BruteForceBase,
826+
LucasCheck::AlmostExtraStrong,
827+
);
828+
assert_eq!(res, Primality::Prime);
829+
}
830+
815831
#[cfg(feature = "tests-exhaustive")]
816832
#[test]
817833
fn exhaustive() {

0 commit comments

Comments
 (0)