public void CompileConstraints() { testSections.ParametersSection.Content = "double a = 3.0;"; testSections.ConstraintsSection.Constraints = new List <RawConstraint>() { new RawConstraint() { Lhs = "x[0]", Rhs = "0", Operator = ">=", Type = ConstraintType.GreaterEqual }, new RawConstraint() { Lhs = "x[1] - 100", Rhs = "0", Operator = "<=", Type = ConstraintType.LessEqual }, new RawConstraint() { Lhs = "x[0] * a", Rhs = "0", Operator = "<=", Type = ConstraintType.LessEqual }, new RawConstraint() { Lhs = "x[1]", Rhs = "200.0", Operator = "<=", Type = ConstraintType.LessEqual } }; var constraints = parser.compileConstraints(testSections); Assert.AreEqual(4, constraints.Count); Assert.AreEqual(ConstraintType.GreaterEqual, constraints[0].Type); Assert.AreEqual(ConstraintType.LessEqual, constraints[1].Type); Assert.AreEqual(2.0, constraints[0].Function(makePoint(2.0, 0.0))); Assert.AreEqual(3.0, constraints[0].Function(makePoint(3.0, 2.0))); Assert.AreEqual(-100.0, constraints[1].Function(makePoint(3.0, 0.0))); Assert.AreEqual(-110.0, constraints[1].Function(makePoint(0.0, -10.0))); Assert.AreEqual(0.0, constraints[2].Function(makePoint(0.0, 0.0))); Assert.AreEqual(9.0, constraints[2].Function(makePoint(3.0, 0.0))); Assert.AreEqual(-200.0, constraints[3].Function(makePoint(0.0, 0.0))); Assert.AreEqual(-100.0, constraints[3].Function(makePoint(0.0, 100.0))); }