コード例 #1
0
 /**
  * Generates the GenericUnaryExpression values for a value and operator
  *
  * @param value the value for which the other case has to be generated
  * @param operator the operator of the binary expression
  * @param leftVariable whether the left side is the variable (true), or the right side (false)
  * @return two GenericUnaryExpression values to condition coverage the binary expression
  */
 public List<GenericAbstractElement> possibleUnaryExpressions(
     GenericUnaryExpression expression, GenericBinaryOperator operator, boolean leftVariable) {
   List<GenericAbstractElement> result = new ArrayList<GenericAbstractElement>();
   GenericUnaryOperator unaryOperator = expression.getOperator();
   switch (unaryOperator) {
     case NEGATE:
       if (expression.getExpression() instanceof GenericBoolean) {
         List<GenericAbstractElement> booleans =
             possibleBooleans(((GenericBoolean) expression.getExpression()).getValue(), operator);
         for (GenericAbstractElement element : booleans) {
           result.add(new GenericUnaryExpression(element, unaryOperator));
         }
       }
       return result;
     case POSITIVE:
       if (expression.getExpression() instanceof GenericNumber) {
         List<GenericAbstractElement> numbers =
             possibleNumbers(
                 ((GenericNumber) expression.getExpression()).getValue(), operator, leftVariable);
         for (GenericAbstractElement element : numbers) {
           result.add(new GenericUnaryExpression(element, unaryOperator));
         }
       }
       return result;
     case NEGATIVE:
       if (expression.getExpression() instanceof GenericNumber) {
         List<GenericAbstractElement> numbers =
             possibleNumbers(
                 ((GenericNumber) expression.getExpression()).getValue(), operator, !leftVariable);
         for (GenericAbstractElement element : numbers) {
           result.add(new GenericUnaryExpression(element, unaryOperator));
         }
       }
       return result;
   }
   return result;
 }
コード例 #2
0
 /**
  * Checks whether the unary expression contains a binary expression with unassigned variables by
  * checking its child expression
  *
  * @param expression the GenericUnaryExpression to be checked
  */
 public void check(GenericUnaryExpression expression) {
   check(expression.getExpression());
 }