Example #1
0
        public void CubicSum()
        {
            var start  = random.Next(1, 100);
            var end    = random.Next(start + 1, 200);
            var uStart = (uint)start;
            var uEnd   = (uint)end;

            Assert.Equal(Enumerable.Range(1, end).Sum(x => x * x * x), (int)MathX.CubicSum(uEnd));
            Assert.Equal(Enumerable.Range(start, end - start + 1).Sum(x => x * x * x), (int)MathX.CubicSum(uStart, uEnd));
            Assert.Throws <InvalidOperationException>(() => MathX.CubicSum(uEnd, uStart));
            Assert.Equal(8u, MathX.CubicSum(2, 2));
            Assert.Equal(225u, MathX.CubicSum(0, 5));
        }