Expand residue thread coverage tests
This commit is contained in:
1 parent
e148f5b6bc
commit
33aeb88c87
3 files changed
+264
-16
No files matched your search
@@ -33,19 +33,52 @@ public class MersenneNumberResidueCpuTesterTests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(31UL)]
|
||||
[Trait("Category", "Fast")]
|
||||
public void Scan_matches_cli_residue_configuration_for_primes(ulong exponent)
|
||||
{
|
||||
RunCase(new MersenneNumberResidueCpuTester(), exponent, 32UL, expectedPrime: true);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(31UL, 1_024UL, 1UL)]
|
||||
[InlineData(31UL, 512UL, 2UL)]
|
||||
[InlineData(31UL, 256UL, 4UL)]
|
||||
[InlineData(127UL, 256UL, 1UL)]
|
||||
[InlineData(127UL, 128UL, 2UL)]
|
||||
[InlineData(127UL, 64UL, 4UL)]
|
||||
[Trait("Category", "Fast")]
|
||||
public void Scan_handles_multiple_residue_sets_for_known_primes(ulong exponent, ulong perSetLimit, ulong setCount)
|
||||
{
|
||||
ulong overallLimit = perSetLimit * setCount;
|
||||
RunCase(new MersenneNumberResidueCpuTester(), exponent, perSetLimit, setCount, overallLimit, expectedPrime: true);
|
||||
}
|
||||
|
||||
private static void RunCase(MersenneNumberResidueCpuTester tester, ulong exponent, ulong maxK, bool expectedPrime)
|
||||
{
|
||||
RunCase(tester, exponent, maxK, 1UL, maxK, expectedPrime);
|
||||
}
|
||||
|
||||
private static void RunCase(
|
||||
MersenneNumberResidueCpuTester tester,
|
||||
ulong exponent,
|
||||
ulong perSetLimit,
|
||||
ulong setCount,
|
||||
ulong overallLimit,
|
||||
bool expectedPrime)
|
||||
{
|
||||
bool isPrime = true;
|
||||
bool exhausted = false;
|
||||
tester.Scan(
|
||||
exponent,
|
||||
(UInt128)exponent << 1,
|
||||
LastDigitIsSeven(exponent),
|
||||
(UInt128)maxK,
|
||||
UInt128.One,
|
||||
(UInt128)maxK,
|
||||
ref isPrime,
|
||||
ref exhausted);
|
||||
exponent,
|
||||
(UInt128)exponent << 1,
|
||||
LastDigitIsSeven(exponent),
|
||||
(UInt128)perSetLimit,
|
||||
(UInt128)setCount,
|
||||
(UInt128)overallLimit,
|
||||
ref isPrime,
|
||||
ref exhausted);
|
||||
isPrime.Should().Be(expectedPrime);
|
||||
exhausted.Should().BeTrue();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user