public void Power() { Assert.AreEqual(0, GeneralMath.Power(5, -1)); Assert.AreEqual(0L, GeneralMath.Power(5L, -1)); Assert.AreEqual(0, GeneralMath.Power(0, 5)); Assert.AreEqual(0, GeneralMath.Power(0, 1)); Assert.Throws <InvalidOperationException>(() => GeneralMath.Power(0, 0)); Assert.AreEqual(0L, GeneralMath.Power(0L, 5)); Assert.AreEqual(0L, GeneralMath.Power(0L, 1)); Assert.Throws <InvalidOperationException>(() => GeneralMath.Power(0L, 0)); for (int b = 1; b < 5; b++) { int currentBase = 1; for (int exponent = 0; exponent < 16; exponent++) { Assert.AreEqual(currentBase, GeneralMath.Power(b, exponent)); Assert.AreEqual((long)currentBase, GeneralMath.Power((long)b, exponent)); currentBase *= b; } } }
public void CustomPowerInt64() { GeneralMath.Power(Base, (long)Exponent); }
public void CustomPowerInt32() { GeneralMath.Power(Base, Exponent); }