public void solveTest() { var inputData = new Dictionary <double, string>() { [-67] = "-12x3+3x2+5x+7", [23] = "+23", [-2869983] = "-99999x5+9999x3+9999x2+99999x+9999", }; foreach (var testRow in inputData) { var coefs = ParseModule.parseAll(testRow.Value); var rez = ComputingModule.calculatePolynom(coefs, 2); Assert.AreEqual(testRow.Key, rez); } }
public void ParseAll() { var testPolynoms = new Dictionary <string, List <int> >() { ["5"] = new List <int>() { 5 }, // + ["-5"] = new List <int>() { -5 }, //+ ["x+5"] = new List <int>() { 1, 5 }, ["2x2+3x+5"] = new List <int>() { 2, 3, 5 }, // + ["-2x2+3x+5"] = new List <int>() { -2, 3, 5 }, ["-12x2+3x+5"] = new List <int>() { -12, 3, 5 }, ["-12x3+3x2+5x+7"] = new List <int>() { -12, 3, 5, 7 } }; foreach (var testCase in testPolynoms) { Assert.AreEqual( string.Join("", testCase.Value.Select(x => x.ToString()).ToArray()), string.Join("", ParseModule.parseAll(testCase.Key).Select(x => x.ToString()).ToArray()) ); } }