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
        {
            float x = TestLibrary.Generator.GetSingle(-55);
            while (x <= 0)
            {
                x = TestLibrary.Generator.GetSingle(-55);
            }

            float y     = 0;
            float angle = MathF.Atan2(y, x);
            if (!MathFTestLib.SingleIsWithinEpsilon(angle, 0.0f))
            {
                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);
    }
    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
        {
            float x = 0;
            float y = TestLibrary.Generator.GetSingle(-55);
            while (y >= 0)
            {
                y = -TestLibrary.Generator.GetSingle(-55);
            }
            float angle = MathF.Atan2(y, x);
            if (!MathFTestLib.SingleIsWithinEpsilon(angle, -MathF.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);
    }
Exemple #3
0
    public bool PosTest2()
    {
        bool retVal = true;

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

        try
        {
            float variable = TestLibrary.Generator.GetSingle(-55);
            float value1   = MathF.Cosh(variable);
            float value2   = MathF.Cosh(-variable);

            if (!MathFTestLib.SingleIsWithinEpsilon(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);
    }
    public bool PosTest4()
    {
        bool retVal = true;

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

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

        return(retVal);
    }
Exemple #5
0
    public bool PosTest1()
    {
        bool retVal = true;

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

        try
        {
            float var1 = 100.1f * TestLibrary.Generator.GetSingle(-55);
            float var2 = 100.1f * TestLibrary.Generator.GetSingle(-55);

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

        return(retVal);
    }
Exemple #6
0
    public bool PosTest4()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest4: Calculate the tangent of 45 degrees");
        try
        {
            float sourceA = 45.0f;
            float desA    = MathF.Tan(sourceA * (MathF.PI / 180));
            if (!MathFTestLib.SingleIsWithinEpsilon(desA, 1.0f))
            {
                TestLibrary.TestFramework.LogError("007", "Expected: 1.0, actual: " + desA.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception" + e);
            retVal = false;
        }
        return(retVal);
    }
    public bool PosTest7()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest7: tanh(+inf) = 1");
        try
        {
            float sourceA = float.PositiveInfinity;
            float desA    = MathF.Tanh(sourceA);
            if (!MathFTestLib.SingleIsWithinEpsilon(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);
    }
Exemple #8
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Caculate the tangent of 0 degrees");
        try
        {
            float sourceA = (float)0;
            float desA    = MathF.Tan(sourceA);
            if (!MathFTestLib.SingleIsWithinEpsilon(desA, (float)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);
    }
Exemple #9
0
    public bool PosTest7()
    {
        bool retVal = true;

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

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

        return(retVal);
    }
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Calculate the tanh of 180 degrees");
        try
        {
            float sourceA = 180;
            float desA    = MathF.Tan(sourceA * (MathF.PI / 180));
            if (!MathFTestLib.SingleIsWithinEpsilon(desA, -0.0f))
            {
                TestLibrary.TestFramework.LogError("005", "Expected: -0.0, actual: " + desA.ToString() + "; diff > epsilon = " +
                                                   MathFTestLib.Epsilon.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception" + e);
            retVal = false;
        }
        return(retVal);
    }
Exemple #11
0
    public bool PosTest3()
    {
        bool retVal = true;

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

        try
        {
            float angle = MathF.Acos(1);
            if (!MathFTestLib.SingleIsWithinEpsilon(angle, 0))
            {
                TestLibrary.TestFramework.LogError("005", "Expected 1, got " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Exemple #12
0
    public bool PosTest7()
    {
        bool retVal = true;

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

        try
        {
            float angle = MathF.Acos(-MathF.Sqrt(3) / 2);
            if (!MathFTestLib.SingleIsWithinEpsilon(angle, 2.61799388f))
            {
                TestLibrary.TestFramework.LogError("013", "Expected: 2.61799388, actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("014", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Exemple #13
0
    public bool PosTest5()
    {
        bool retVal = true;

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

        try
        {
            float angle = MathF.Acos(-0.5f);
            if (!MathFTestLib.SingleIsWithinEpsilon(angle, 2.09439510f))
            {
                TestLibrary.TestFramework.LogError("009", "Expected: 2.09439510, actual: " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Exemple #14
0
    public bool PosTest4()
    {
        bool retVal = true;

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

        try
        {
            float angle = MathF.Acos(0.5f);
            if (!MathFTestLib.SingleIsWithinEpsilon(angle, 1.04719755f))
            {
                TestLibrary.TestFramework.LogError("007", "Expected 1.04719755, got " + angle.ToString());
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Exemple #15
0
    public bool PosTest3()
    {
        bool retVal = true;

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

        try
        {
            float f = MathF.Sinh(-MathF.PI / 2);
            if (!MathFTestLib.SingleIsWithinEpsilon(f, -2.30129890f))
            {
                TestLibrary.TestFramework.LogError("P03.1", "The result is error when radian is -MathF.PI/2!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P03.2", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Exemple #16
0
    public bool PosTest4()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest4: Verify the result when radian is MathF.PI/6.");

        try
        {
            float f = MathF.Sinh(MathF.PI / 6);
            if (!MathFTestLib.SingleIsWithinEpsilon(f, 0.547853474f))
            {
                TestLibrary.TestFramework.LogError("P04.1", "The result is error when radian is MathF.PI/6!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("P04.2", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return(retVal);
    }
Exemple #17
0
    public bool PosTest3()
    {
        bool retVal = true;

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

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

        return(retVal);
    }
    public bool PosTest2()
    {
        bool retVal = true;

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

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

        return(retVal);
    }
    public bool PosTest3()
    {
        bool retVal = true;

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

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

        return(retVal);
    }
Exemple #20
0
    public bool PosTest1()
    {
        bool retVal = true;

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

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

        return(retVal);
    }
    public bool PosTest5()
    {
        bool retVal = true;

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

        try
        {
            float angle    = MathF.Atan(float.NegativeInfinity - 1);
            float baseline = MathF.Atan(float.NegativeInfinity);
            if (!MathFTestLib.SingleIsWithinEpsilon(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);
    }
Exemple #22
0
    public bool PosTest3()
    {
        bool retVal = true;

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

        try
        {
            float zero  = 0;
            float value = MathF.Cosh(zero);
            if (!MathFTestLib.SingleIsWithinEpsilon(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);
    }