Esempio n. 1
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify the evenness of cosh function [cosh(x)=cosh(-x)]");

        try
        {
            double variable = TestLibrary.Generator.GetDouble(-55);
            double value1   = Math.Cosh(variable);
            double value2   = Math.Cosh(-variable);

            if (!MathTestLib.DoubleIsWithinEpsilon(value1, value2))
            {
                TestLibrary.TestFramework.LogError("003", "The parity of cosh should be even function!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 2
0
    public bool PosTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Verify the angle of arctan(x,y) when the point in negative direction of Y axis...");

        try
        {
            double x = 0;
            double y = TestLibrary.Generator.GetDouble(-55);
            while (y >= 0)
            {
                y = -TestLibrary.Generator.GetDouble(-55);
            }
            double angle = Math.Atan2(y, x);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, -Math.PI / 2))
            {
                TestLibrary.TestFramework.LogError("009", "The angle should be -pi/2, actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 3
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify the angle of arctan(x,y) when the point in forward direction of X axis...");

        try
        {
            double x = TestLibrary.Generator.GetDouble(-55);
            while (x <= 0)
            {
                x = TestLibrary.Generator.GetDouble(-55);
            }

            double y     = 0;
            double angle = Math.Atan2(y, x);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, 0.0))
            {
                TestLibrary.TestFramework.LogError("005", "The angle should be zero,actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 4
0
    public bool PosTest4()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest4: Verify the value of atn(inf+1)=atn(inf)");

        try
        {
            double angle    = Math.Atan(double.PositiveInfinity + 1);
            double baseline = Math.Atan(double.PositiveInfinity);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, baseline))
            {
                TestLibrary.TestFramework.LogError("007", "Expected: " + baseline.ToString() + ", actual: " +
                                                   angle.ToString() + " diff>epsilon= " + MathTestLib.Epsilon.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 5
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify the monotonicity of ln(d)...");

        try
        {
            double var1 = 100.1 * TestLibrary.Generator.GetDouble(-55);
            double var2 = 100.1 * TestLibrary.Generator.GetDouble(-55);

            if (var1 < var2)
            {
                if (Math.Log(var1) >= Math.Log(var2))
                {
                    TestLibrary.TestFramework.LogError("001", "The value of ln(var1)=" + Math.Log(var1).ToString() +
                                                       " should be less than ln(var2)=" + Math.Log(var2).ToString());
                    retVal = false;
                }
            }
            else if (var1 > var2)
            {
                if (Math.Log(var1) <= Math.Log(var2))
                {
                    TestLibrary.TestFramework.LogError("002", "The value of ln(var1)=" + Math.Log(var1).ToString() +
                                                       " should be larger than ln(var2)=" + Math.Log(var2).ToString());
                    retVal = false;
                }
            }
            else
            {
                if (!MathTestLib.DoubleIsWithinEpsilon(Math.Log(var1), Math.Log(var2)))
                {
                    TestLibrary.TestFramework.LogError("003", "The value of ln(var1)=" + Math.Log(var1).ToString() +
                                                       " should be equal to ln(var2)=" + Math.Log(var2).ToString());
                    retVal = false;
                }
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 6
0
    public bool PosTest4()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest4: Calculate the tangent of 45 degrees");
        try
        {
            double sourceA = 45.0;
            double desA    = Math.Tan(sourceA * (Math.PI / 180));
            if (!MathTestLib.DoubleIsWithinEpsilon(desA, 0.99999999999999989))
            {
                TestLibrary.TestFramework.LogError("007", "Expected: 0.99999999999999989, actual: " + desA.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 7
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Caculate the tangent of 0 degrees");
        try
        {
            double sourceA = (double)0;
            double desA    = Math.Tan(sourceA);
            if (!MathTestLib.DoubleIsWithinEpsilon(desA, (double)0))
            {
                TestLibrary.TestFramework.LogError("001", "Expected: 0, actual: " + desA.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 8
0
    public bool PosTest7()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest7: tanh(+inf) = 1");
        try
        {
            double sourceA = Double.PositiveInfinity;
            double desA    = Math.Tanh(sourceA);
            if (!MathTestLib.DoubleIsWithinEpsilon(desA, 1))
            {
                TestLibrary.TestFramework.LogError("013", "Expected 1, actual: " + desA.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("014", "Unexpected exception" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 9
0
    public bool PosTest6()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest6: Verify the value of Arccos(Math.Sqrt(3)/2) is Math.PI/6...");

        try
        {
            double angle = Math.Acos(Math.Sqrt(3) / 2);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, 0.52359877559829893))
            {
                TestLibrary.TestFramework.LogError("011", "Expected: 0.52359877559829893, actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("012", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 10
0
    public bool PosTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Verify the value of Arccos(-0.5) is 2*Math.PI/3...");

        try
        {
            double angle = Math.Acos(-0.5);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, 2.0943951023931957))
            {
                TestLibrary.TestFramework.LogError("009", "Expected: 2.09439510239319573, actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 11
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Calculate the tanh of 90 degrees");
        try
        {
            double sourceA = 90;
            double desA    = Math.Tanh(sourceA * (Math.PI / 180));
            if (!MathTestLib.DoubleIsWithinEpsilon(desA, 0.91715233566727439))
            {
                TestLibrary.TestFramework.LogError("003", "Expected: 0.91715233566727439, actual: " + desA.ToString() + "; diff > epsilon = " +
                                                   MathTestLib.Epsilon.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 12
0
    public bool PosTest7()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest7: Verify the value of ln(e)...");

        try
        {
            double var = Math.E;
            if (!MathTestLib.DoubleIsWithinEpsilon(Math.Log(var), 1))
            {
                TestLibrary.TestFramework.LogError("015", "The value should be equal to 1, is " + Math.Log(var).ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("016", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 13
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify the value of ln(1) is 0...");

        try
        {
            double var = 1;
            if (!MathTestLib.DoubleIsWithinEpsilon(Math.Log(var), 0))
            {
                TestLibrary.TestFramework.LogError("007", "The value of ln(1) should be zero, is " + Math.Log(var).ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 14
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Calculate the tanh of 180 degrees");
        try
        {
            double sourceA = 180;
            double desA    = Math.Tan(sourceA * (Math.PI / 180));
            if (!MathTestLib.DoubleIsWithinEpsilon(desA, -0.00000000000000012246063538223773))
            {
                TestLibrary.TestFramework.LogError("005", "Expected: -0.00000000000000012246063538223773, actual: " + desA.ToString() + "; diff > epsilon = " +
                                                   MathTestLib.Epsilon.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception" + e);
            retVal = false;
        }
        return(retVal);
    }
Esempio n. 15
0
    public bool PosTest7()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest7: Verify the value of Arccos(-Math.Sqrt(3)/2) is 5*Math.PI/6...");

        try
        {
            double angle = Math.Acos(-Math.Sqrt(3) / 2);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, 2.6179938779914944))
            {
                TestLibrary.TestFramework.LogError("013", "Expected: 2.617993877991494, actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("014", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 16
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify the result when radian is -Math.PI/2.");

        try
        {
            Double d = Math.Sinh(-Math.PI / 2);
            if (!MathTestLib.DoubleIsWithinEpsilon(d, -2.3012989023072947))
            {
                TestLibrary.TestFramework.LogError("P03.1", "The result is error when radian is -Math.PI/2!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P03.2", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 17
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify the result when radian is 0.");

        try
        {
            Double d = Math.Sinh(0);
            if (!MathTestLib.DoubleIsWithinEpsilon(d, 0))
            {
                TestLibrary.TestFramework.LogError("P01.1", "The result is error when radian is 0!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P01.2", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 18
0
    public bool PosTest4()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest4: Verify the value of Arccos(0.5) is Math.PI/3...");

        try
        {
            double angle = Math.Acos(0.5);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, 1.0471975511965979))
            {
                TestLibrary.TestFramework.LogError("007", "Expected 1.0471975511965979, got " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 19
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify the value of Arccos(0) is Math.PI/2...");

        try
        {
            double angle = Math.Acos(0);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, Math.PI / 2))
            {
                TestLibrary.TestFramework.LogError("003", "Expected pi/2, got " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 20
0
    public bool PosTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Verify the result when radian is -Math.PI/6.");

        try
        {
            Double d = Math.Sinh(-Math.PI / 6);
            if (!MathTestLib.DoubleIsWithinEpsilon(d, -0.54785347388803973))
            {
                TestLibrary.TestFramework.LogError("P05.1", "The result is error when radian is -Math.PI/6!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P05.2", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 21
0
    public bool PosTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Verify atn(-inf -1)=atn(-inf)");

        try
        {
            double angle    = Math.Atan(double.NegativeInfinity - 1);
            double baseline = Math.Atan(double.NegativeInfinity);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, baseline))
            {
                TestLibrary.TestFramework.LogError("009", "Expected " + baseline.ToString() + ", actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 22
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify the value of arctan(PositiveInfinity) is Math.PI/2...");

        try
        {
            double angle = Math.Atan(double.PositiveInfinity);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, Math.PI / 2))
            {
                TestLibrary.TestFramework.LogError("003", "Expected: pi/2, actual: " +
                                                   angle.ToString() + " diff>epsilon= " + MathTestLib.Epsilon.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 23
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify the value of arctan(0) is zero...");

        try
        {
            double angle = Math.Atan(0);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, 0))
            {
                TestLibrary.TestFramework.LogError("005", "Expected: 0, actual: " +
                                                   angle.ToString() + " diff>epsilon= " + MathTestLib.Epsilon.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 24
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Verify the value of cosh(0) = 1...");

        try
        {
            double zero  = 0;
            double value = Math.Cosh(zero);
            if (!MathTestLib.DoubleIsWithinEpsilon(value, 1))
            {
                TestLibrary.TestFramework.LogError("005", "The value of cosh(0) should be 1, actual: " + value.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 25
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify the value of Arccos(-1) is Math.PI...");

        try
        {
            double angle = Math.Acos(-1);
            if (!MathTestLib.DoubleIsWithinEpsilon(angle, Math.PI))
            {
                TestLibrary.TestFramework.LogError("001", "Expected Math.Acos(-1) = " + Math.PI.ToString() + ", received " +
                                                   angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }