System.Numerics.Tests.logTest.RunLogTests C# (CSharp) Method

RunLogTests() private method

private RunLogTests ( ) : void
return void
        public static void RunLogTests()
        {
            byte[] tempByteArray1 = new byte[0];
            byte[] tempByteArray2 = new byte[0];
            BigInteger bi;

            // Log Method - Log(1,+Infinity)
            Assert.Equal(0, BigInteger.Log(1, Double.PositiveInfinity));

            // Log Method - Log(1,0)
            VerifyLogString("0 1 bLog");

            // Log Method - Log(0, >1)
            for (int i = 0; i < s_samples; i++)
            {
                tempByteArray1 = GetRandomPosByteArray(s_random, 10);
                VerifyLogString(Print(tempByteArray1) + "0 bLog");
            }

            // Log Method - Log(0, 0>x>1)
            for (int i = 0; i < s_samples; i++)
            {
                Assert.Equal(Double.PositiveInfinity, BigInteger.Log(0, s_random.NextDouble()));
            }

            // Log Method - base = 0
            for (int i = 0; i < s_samples; i++)
            {
                bi = 1;
                while (bi == 1)
                {
                    bi = new BigInteger(GetRandomPosByteArray(s_random, 8));
                }
                Assert.True((Double.IsNaN(BigInteger.Log(bi, 0))));
            }

            // Log Method - base = 1
            for (int i = 0; i < s_samples; i++)
            {
                tempByteArray1 = GetRandomByteArray(s_random);
                VerifyLogString("1 " + Print(tempByteArray1) + "bLog");
            }

            // Log Method - base = NaN
            for (int i = 0; i < s_samples; i++)
            {
                Assert.True(Double.IsNaN(BigInteger.Log(new BigInteger(GetRandomByteArray(s_random, 10)), Double.NaN)));
            }

            // Log Method - base = +Infinity
            for (int i = 0; i < s_samples; i++)
            {
                Assert.True(Double.IsNaN(BigInteger.Log(new BigInteger(GetRandomByteArray(s_random, 10)), Double.PositiveInfinity)));
            }

            // Log Method - Log(0,1)
            VerifyLogString("1 0 bLog");

            // Log Method - base < 0
            for (int i = 0; i < s_samples; i++)
            {
                tempByteArray1 = GetRandomByteArray(s_random, 10);
                tempByteArray2 = GetRandomNegByteArray(s_random, 1);
                VerifyLogString(Print(tempByteArray2) + Print(tempByteArray1) + "bLog");
                Assert.True(Double.IsNaN(BigInteger.Log(new BigInteger(GetRandomByteArray(s_random, 10)), -s_random.NextDouble())));
            }

            // Log Method - value < 0
            for (int i = 0; i < s_samples; i++)
            {
                tempByteArray1 = GetRandomNegByteArray(s_random, 10);
                tempByteArray2 = GetRandomPosByteArray(s_random, 1);
                VerifyLogString(Print(tempByteArray2) + Print(tempByteArray1) + "bLog");
            }

            // Log Method - Small BigInteger and 0<base<0.5 
            for (int i = 0; i < s_samples; i++)
            {
                BigInteger temp = new BigInteger(GetRandomPosByteArray(s_random, 10));
                Double newbase = Math.Min(s_random.NextDouble(), 0.5);
                Assert.True(ApproxEqual(BigInteger.Log(temp, newbase), Math.Log((double)temp, newbase)));
            }

            // Log Method - Large BigInteger and 0<base<0.5 
            for (int i = 0; i < s_samples; i++)
            {
                BigInteger temp = new BigInteger(GetRandomPosByteArray(s_random, s_random.Next(1, 100)));
                Double newbase = Math.Min(s_random.NextDouble(), 0.5);
                Assert.True(ApproxEqual(BigInteger.Log(temp, newbase), Math.Log((double)temp, newbase)));
            }

            // Log Method - two small BigIntegers
            for (int i = 0; i < s_samples; i++)
            {
                tempByteArray1 = GetRandomPosByteArray(s_random, 2);
                tempByteArray2 = GetRandomPosByteArray(s_random, 3);
                VerifyLogString(Print(tempByteArray1) + Print(tempByteArray2) + "bLog");
            }

            // Log Method - one small and one large BigIntegers
            for (int i = 0; i < s_samples; i++)
            {
                tempByteArray1 = GetRandomPosByteArray(s_random, 1);
                tempByteArray2 = GetRandomPosByteArray(s_random, s_random.Next(1, 100));
                VerifyLogString(Print(tempByteArray1) + Print(tempByteArray2) + "bLog");
            }

            // Log Method - two large BigIntegers
            for (int i = 0; i < s_samples; i++)
            {
                tempByteArray1 = GetRandomPosByteArray(s_random, s_random.Next(1, 100));
                tempByteArray2 = GetRandomPosByteArray(s_random, s_random.Next(1, 100));
                VerifyLogString(Print(tempByteArray1) + Print(tempByteArray2) + "bLog");
            }

            // Log Method - Very Large BigInteger 1 << 128 << Int.MaxValue and 2
            LargeValueLogTests(128, 1);

        }