public void CalculatesFloorCorrectly(ulong divisor, ulong testDividend) { var uInt64Divisor = new UInt64Divisor(divisor); var rounded = uInt64Divisor.Floor(testDividend); Assert.AreEqual(testDividend / divisor * divisor, rounded, SerializeDivisor(uInt64Divisor)); }
public void CalculatesFloorCorrectlyRandomNumerators(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 rounded = uInt64Divisor.Floor(testDividend); Assert.AreEqual(testDividend / divisor * divisor, rounded, $"Trying to test {testDividend} / {SerializeDivisor(uInt64Divisor)} * {SerializeDivisor(uInt64Divisor)}"); } }