Accord.Tests.Math.NonlinearConstraintTest.GetViolationTest1 C# (CSharp) Method

GetViolationTest1() private method

private GetViolationTest1 ( ) : void
return void
        public void GetViolationTest1()
        {
            NonlinearConstraint[] targets =
            {
                new NonlinearConstraint(1, x => x[0] >= 1),
                new NonlinearConstraint(1, x => x[0] <= 1)
            };

            double[] expected;
            
            expected = new double[] { -0.5, 0.5 };
            for (int i = 0; i < targets.Length; i++)
            {
                double e = expected[i];
                double a = targets[i].GetViolation(new double[] { 0.5 });

                Assert.AreEqual(e, a);
            }

            expected = new double[] { 0.5, -0.5 };
            for (int i = 0; i < targets.Length; i++)
            {
                double e = expected[i];
                double a = targets[i].GetViolation(new double[] { 1.5 });

                Assert.AreEqual(e, a);
            }
        }