public void DivRemReturnsCorrectly(ulong divisor, ulong testDividend) { var uInt64Divisor = new UInt64Divisor(divisor); var remainder = uInt64Divisor.DivRem(testDividend, out var quotient); Assert.Multiple(() => { Assert.AreEqual(testDividend % divisor, remainder, SerializeDivisor(uInt64Divisor)); Assert.AreEqual(testDividend / divisor, quotient, SerializeDivisor(uInt64Divisor)); }); }
public void DivRemReturnsCorrectlyRandomNumerators(ulong divisor) { var uInt64Divisor = new UInt64Divisor(divisor); var rng = new PcgRandom(); for (ulong i = 0; i < RandomTestCount; i++) { var testDividend = rng.Next() | ((ulong)rng.Next() << 32); var remainder = uInt64Divisor.DivRem(testDividend, out var quotient); Assert.AreEqual(testDividend % divisor, remainder, $"Trying to test {testDividend} % {SerializeDivisor(uInt64Divisor)}"); Assert.AreEqual(testDividend / divisor, quotient, $"Trying to test {testDividend} / {SerializeDivisor(uInt64Divisor)}"); } }