public void TestExtraVariable() { EquationConversion.ResetEquationConversion(); Consolidate.Initialize(); // test-input variableNotInFunction string varToken = EquationConversion.GetVariableToken(); Consolidate.ConvertAndCheckInputs("x+y", "x,2,3\ny,4,5\nz,6,7", Solver.GetValidOperators(), Solver.GetValidTerminators(), "\n", ","); EquationStruct eqRoot = Consolidate.GetEquationStruct(); IntervalStruct[] vars = Consolidate.GetIntervalStructList(); EquationStruct targetStructure = new EquationStruct("+", "", new EquationStruct(varToken, "x", null, null), new EquationStruct(varToken, "y", null, null)); IntervalStruct[] targetIntervals = new IntervalStruct[] { new IntervalStruct("x", 2, 3, true, true), new IntervalStruct("y", 4, 5, true, true) }; Assert.AreEqual(PrintEquation(targetStructure), PrintEquation(eqRoot)); Assert.AreEqual(targetIntervals[0].GetVariableName(), vars[0].GetVariableName()); Assert.AreEqual(targetIntervals[0].GetMinBound(), vars[0].GetMinBound()); Assert.AreEqual(targetIntervals[0].GetMaxBound(), vars[0].GetMaxBound()); Assert.AreEqual(targetIntervals[1].GetVariableName(), vars[1].GetVariableName()); Assert.AreEqual(targetIntervals[1].GetMinBound(), vars[1].GetMinBound()); Assert.AreEqual(targetIntervals[1].GetMaxBound(), vars[1].GetMaxBound()); Assert.AreEqual(2, vars.Length); }
public void TestIncompleteEquation() { EquationConversion.ResetEquationConversion(); Consolidate.Initialize(); // unittest-consolidateincompleteequation int successCode = Consolidate.ConvertAndCheckInputs("", "x,2,3\n", Solver.GetValidOperators(), Solver.GetValidTerminators(), Input.GetLineDelimiter(), Input.GetFieldDelimiter()); Assert.AreEqual(-3, successCode); }
public void TestMissingVariable() { EquationConversion.ResetEquationConversion(); Consolidate.Initialize(); // test-input noDomain int success = Consolidate.ConvertAndCheckInputs("x+y", "x,2,3", Solver.GetValidOperators(), Solver.GetValidTerminators(), System.Environment.NewLine, ","); Assert.AreEqual(-2, success); }
public void TestFailedConfig() { EquationConversion.ResetEquationConversion(); Consolidate.Initialize(); // unittest-consolidatenoops OperatorStruct[] ops = new OperatorStruct[] { }; int success = Consolidate.ConvertAndCheckInputs("x+y", "x,2,3\ny,4,5", ops, Solver.GetValidTerminators(), System.Environment.NewLine, ","); Assert.AreEqual(-1, success); // unittest-consolidatenorightterm string[][] terminators = new string[][] { new string[] { "(", "" } }; success = Consolidate.ConvertAndCheckInputs("x+y", "x,2,3\ny,4,5", Solver.GetValidOperators(), terminators, System.Environment.NewLine, ","); Assert.AreEqual(-1, success); // unittest-consolidatenoleftterm terminators = new string[][] { new string[] { "", ")" } }; success = Consolidate.ConvertAndCheckInputs("x+y", "x,2,3\ny,4,5", Solver.GetValidOperators(), terminators, System.Environment.NewLine, ","); Assert.AreEqual(-1, success); }