public void E_Sim_Instead_Sin_Test() { FunctionInformation_V2 FI = new FunctionInformation_V2("2 * sim (x) + 3 * cos(y) - sin (z) / cos(z)"); var dict = new Dictionary <string, double>(new List <KeyValuePair <string, double> > { new KeyValuePair <string, double>("x", pi / 2), new KeyValuePair <string, double>("y", pi), new KeyValuePair <string, double>("z", pi / 4) }); var firstValue = FI.GetValue(dict); FI.FixValue("x", pi / 2); FI.FixValue("y", pi); FI.FixValue("z", pi / 4); var secondValue = FI.GetValue(); Assert.AreEqual(3, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "x", "y", "z" }, FI.GetVariables()); Assert.AreEqual(-2.0, firstValue, delta); Assert.AreEqual(firstValue, secondValue, delta, "Несовпадение значений при вычислении функции двумя способами"); }
public void B_DifferentTestCase_Test_6() { FunctionInformation_V2 FI = new FunctionInformation_V2("cos(z + w) ^ 2 - x * p + y"); var dict = new Dictionary <string, double>(new List <KeyValuePair <string, double> > { new KeyValuePair <string, double>("x", 4), new KeyValuePair <string, double>("y", 11), new KeyValuePair <string, double>("z", pi / 2), new KeyValuePair <string, double>("w", pi / 2), new KeyValuePair <string, double>("p", 3) }); var firstValue = FI.GetValue(dict); FI.FixValue("x", 4); FI.FixValue("y", 11); FI.FixValue("z", pi / 2); FI.FixValue("w", pi / 2); FI.FixValue("p", 3); var secondValue = FI.GetValue(); Assert.AreEqual(3, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "z", "w", "x", "p", "y" }, FI.GetVariables()); Assert.AreEqual(0.0, firstValue, delta); Assert.AreEqual(firstValue, secondValue, delta, "Несовпадение значений при вычислении функции двумя способами"); }
public void B_DifferentTestCase_Test_5() { FunctionInformation_V2 FI = new FunctionInformation_V2("y + sin(x * z) * 2"); var dict = new Dictionary <string, double>(new List <KeyValuePair <string, double> > { new KeyValuePair <string, double>("x", pi), new KeyValuePair <string, double>("y", 3), new KeyValuePair <string, double>("z", 0.5) }); var firstValue = FI.GetValue(dict); FI.FixValue("x", pi); FI.FixValue("y", 3); FI.FixValue("z", 0.5); var secondValue = FI.GetValue(); Assert.AreEqual(2, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "y", "x", "z" }, FI.GetVariables()); Assert.AreEqual(5.0, firstValue, delta); Assert.AreEqual(firstValue, secondValue, delta, "Несовпадение значений при вычислении функции двумя способами"); }
public void A_Base_Equals_DictValue_And_FixValue_Test() { FunctionInformation_V2 FI = new FunctionInformation_V2("x * z + y / p"); var dict = new Dictionary <string, double>(new List <KeyValuePair <string, double> > { new KeyValuePair <string, double>("x", 6), new KeyValuePair <string, double>("y", 2), new KeyValuePair <string, double>("z", 8), new KeyValuePair <string, double>("p", 6), }); var firstValue = FI.GetValue(dict); FI.FixValue("x", 6); FI.FixValue("y", 2); FI.FixValue("z", 8); FI.FixValue("p", 6); var secondValue = FI.GetValue(); Assert.AreEqual(2, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "x", "z", "y", "p" }, FI.GetVariables()); Assert.AreEqual(48.3333333333, firstValue, delta); Assert.AreEqual(firstValue, secondValue, delta); }
public void A_Base_ThreeTermsWithThreeVariables_Test() { FunctionInformation_V2 FI = new FunctionInformation_V2("y - 3 * x + z"); Assert.AreEqual(3, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "y", "x", "z" }, FI.GetVariables()); }
public void A_Base_TwoTermsWithOneVariables_Test() { FunctionInformation_V2 FI = new FunctionInformation_V2("3 * x + 5"); Assert.AreEqual(2, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "x" }, FI.GetVariables()); }
public void A_Base_FixValueAndGetValue_Test() { FunctionInformation_V2 FI = new FunctionInformation_V2("x"); FI.FixValue("x", 2.0); Assert.AreEqual(1, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "x" }, FI.GetVariables()); Assert.AreEqual(2.0, FI.GetValue(), delta); }
public void A_Base_TwoVariablesFixValue_ByDict_Test() { FunctionInformation_V2 FI = new FunctionInformation_V2("x + y"); var dict = new Dictionary <string, double>(new List <KeyValuePair <string, double> > { new KeyValuePair <string, double>("x", 5.0), new KeyValuePair <string, double>("y", 3.5) }); var value = FI.GetValue(dict); Assert.AreEqual(2, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "x", "y" }, FI.GetVariables()); Assert.AreEqual(8.5, value, delta); }
public void B_DifferentTestCase_Test_1() { FunctionInformation_V2 FI = new FunctionInformation_V2("(sin (x) ^ 2) + (cos (x) ^ 2)"); var dict = new Dictionary <string, double>(new List <KeyValuePair <string, double> > { new KeyValuePair <string, double>("x", 6) }); var firstValue = FI.GetValue(dict); FI.FixValue("x", 6); var secondValue = FI.GetValue(); Assert.AreEqual(2, FI.GetTermCount()); Assert.AreEqual(new List <string>() { "x" }, FI.GetVariables()); Assert.AreEqual(1, firstValue, delta); Assert.AreEqual(firstValue, secondValue, delta, "Несовпадение значений при вычислении функции двумя способами"); }