public void CalculatesFloorRemCorrectly(ulong divisor, ulong testDividend) { var uInt64Divisor = new UInt64Divisor(divisor); var remainder = uInt64Divisor.FloorRem(testDividend, out var rounded); Assert.Multiple(() => { Assert.AreEqual(testDividend % divisor, remainder, SerializeDivisor(uInt64Divisor)); Assert.AreEqual(testDividend / divisor * divisor, rounded, SerializeDivisor(uInt64Divisor)); }); }
public void CalculatesFloorRemCorrectlyRandomNumerators(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.FloorRem(testDividend, out var rounded); Assert.AreEqual(testDividend % divisor, remainder, $"Trying to test {testDividend} % {SerializeDivisor(uInt64Divisor)}"); Assert.AreEqual(testDividend / divisor * divisor, rounded, $"Trying to test {testDividend} / {SerializeDivisor(uInt64Divisor)} * {SerializeDivisor(uInt64Divisor)}"); } }