BitContradiction improvements.
This commit is contained in:
1 parent
b453d46c5f
commit
22cc8f368f
7 files changed
+5299
-4230
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using FluentAssertions;
|
||||
using PerfectNumbers.Core.ByDivisor;
|
||||
using Xunit;
|
||||
@@ -22,7 +23,7 @@ public class BitContradictionSolverTests
|
||||
[Fact]
|
||||
public void TryPropagateCarry_FailsWhenParityUnreachable()
|
||||
{
|
||||
CarryRange carry = CarryRange.Single(0);
|
||||
CarryRange carry = CarryRange.Single(0);
|
||||
bool success = TryPropagateCarry(
|
||||
currentCarry: ref carry,
|
||||
forcedOnes: 0,
|
||||
@@ -34,10 +35,34 @@ public class BitContradictionSolverTests
|
||||
carry.Max.Should().Be(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", "Fast")]
|
||||
public void ShouldPruneWithFinalPow2Shift_ReturnsTrue_WhenShiftedResidueStaysBelowModulusAndResidueIsNotOne()
|
||||
{
|
||||
bool shouldPrune = ShouldPruneWithFinalPow2Shift(
|
||||
prefixResidue: new BigInteger(3),
|
||||
modulus: new BigInteger(1000),
|
||||
tailShift: 8);
|
||||
|
||||
shouldPrune.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", "Fast")]
|
||||
public void ShouldPruneWithFinalPow2Shift_ReturnsFalse_WhenResidueIsOne()
|
||||
{
|
||||
bool shouldPrune = ShouldPruneWithFinalPow2Shift(
|
||||
prefixResidue: BigInteger.One,
|
||||
modulus: new BigInteger(1000),
|
||||
tailShift: 8);
|
||||
|
||||
shouldPrune.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryPropagateCarry_ComputesNextCarryRange()
|
||||
{
|
||||
CarryRange carry = new(0, 1);
|
||||
CarryRange carry = new(0, 1);
|
||||
bool success = TryPropagateCarry(
|
||||
currentCarry: ref carry,
|
||||
forcedOnes: 1,
|
||||
|
||||
Reference in new issue
Block a user