示例#1
0
        public void ValidateWithSeveralOperatorsTogether()
        {
            string expression = "+ + 7";
            bool   result     = MathRegex.IsExpressionValid(expression);

            Assert.IsFalse(result);
        }
示例#2
0
        public void ValidateSimpleWrongExpression()
        {
            string expression = "2a7";
            bool   result     = MathRegex.IsExpressionValid(expression);

            Assert.IsFalse(result);
        }
示例#3
0
        public void ValidateWrongExpressionWithValidSubexpression()
        {
            string expression = "2 + 7 - 2 a 3 b";
            bool   result     = MathRegex.IsExpressionValid(expression);

            Assert.IsFalse(result);
        }
示例#4
0
        public void ValidateComplexExpression()
        {
            string expression = "2 + 7 - 2 * 4";
            bool   result     = MathRegex.IsExpressionValid(expression);

            Assert.IsTrue(result);
        }
示例#5
0
        public void ValidateComplexWrongExpression()
        {
            string expression = "2 + 7 a 2 b 4";
            bool   result     = MathRegex.IsExpressionValid(expression);

            Assert.IsFalse(result);
        }
示例#6
0
        public void ValidateFailsNoSpaces()
        {
            string expression = "2+7";
            bool   result     = MathRegex.IsExpressionValid(expression);

            Assert.IsFalse(result);
        }
示例#7
0
        public void ValidateWithSpaces()
        {
            string expression = "2    +   287";
            bool   result     = MathRegex.IsExpressionValid(expression);

            Assert.IsTrue(result);
        }
示例#8
0
        public void ValidateMoreThanOneDigitExpression()
        {
            string expression = "25 + 287";

            bool result = MathRegex.IsExpressionValid(expression);

            Assert.IsTrue(result);
        }
示例#9
0
        public void ValidateSimpleExpressionWithAllOperations()
        {
            string operators  = "+-*/";
            string expression = String.Empty;

            foreach (char operatorChar in operators)
            {
                expression = "2 " + operatorChar + " 2";
                Assert.IsTrue(MathRegex.IsExpressionValid(expression), "Failure with operator: " + operatorChar);
            }
        }
示例#10
0
 public void ValidateWithNegativeNumbers()
 {
     Assert.IsTrue(MathRegex.IsExpressionValid("-7 + 1"));
 }
示例#11
0
 public void ValidateWithNegativeNumbersAtTheEnd()
 {
     Assert.IsTrue(MathRegex.IsExpressionValid("7 - -1"));
 }