public void InValidExpressionTestMethod() { String s1 = "--2+4/2"; Double?expectedresult = null; Double actualresult = ArithmeticPatternMatchingTest.parsethisstring(s1); Assert.AreEqual(expectedresult, actualresult); String s2 = "2+4/2-+"; expectedresult = null; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s2); Assert.AreEqual(expectedresult, actualresult); String s3 = "2+-4/2"; expectedresult = null; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s3); Assert.AreEqual(expectedresult, actualresult); String s4 = "Test"; expectedresult = null; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s4); Assert.AreEqual(expectedresult, actualresult); String s5 = "a+2"; expectedresult = null; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s5); Assert.AreEqual(expectedresult, actualresult); String s6 = "2+3-*4"; expectedresult = null; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s6); Assert.AreEqual(expectedresult, actualresult); }
public void ValidExpressionTestMethod() { String s1 = "2+4/sqrt(4)-4"; Double expectedresult = 0; Double actualresult = ArithmeticPatternMatchingTest.parsethisstring(s1); Assert.AreEqual(expectedresult, actualresult); String s2 = "sqrt(4)+3^3-2"; expectedresult = 27; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s2); Assert.AreEqual(expectedresult, actualresult); String s3 = "1+2+3"; expectedresult = 6; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s3); Assert.AreEqual(expectedresult, actualresult); String s4 = "2-2+3"; expectedresult = 3; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s4); Assert.AreEqual(expectedresult, actualresult); String s5 = "2^2+3*6"; expectedresult = 22; actualresult = ArithmeticPatternMatchingTest.parsethisstring(s5); Assert.AreEqual(expectedresult, actualresult); }