From 9eb944b6b931d07eb5d51b582cb887e7c3470b4a Mon Sep 17 00:00:00 2001 From: nicoo Date: Fri, 19 Jun 2020 13:48:00 +0200 Subject: [PATCH] =?UTF-8?q?factor:=20Add=20test=20exhibiting=20a=20bug=20i?= =?UTF-8?q?n=20=CF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test is repeated 20 times to make it overwhelmingly-likely to fail (the bug itself is only triggered rarely) --- src/uu/factor/src/factor.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index 2445585fb..f10198ca2 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -156,4 +156,12 @@ mod tests { .map(|i| 2 * i + 2u64.pow(32) + 1) .all(|i| factor(i).product() == i)); } + + #[test] + fn factor_recombines_strong_pseudoprime() { + let pseudoprime = 17179869183; + for _ in 0..20 { + assert!(factor(pseudoprime).product() == pseudoprime); + } + } }