Search in sources :

Example 11 with Comparator

use of org.evosuite.symbolic.expr.Comparator in project evosuite by EvoSuite.

the class ConstraintNormalizer method normalizeIntegerConstriant.

private static Constraint<?> normalizeIntegerConstriant(IntegerConstraint c) {
    if (c.getLeftOperand() instanceof IntegerComparison) {
        IntegerComparison cmp = (IntegerComparison) c.getLeftOperand();
        int value = ((Number) c.getRightOperand().getConcreteValue()).intValue();
        Comparator op = c.getComparator();
        Expression<Long> cmp_left = cmp.getLeftOperant();
        Expression<Long> cmp_right = cmp.getRightOperant();
        return createIntegerConstraint(cmp_left, op, cmp_right, value);
    } else {
        assert (c.getRightOperand() instanceof IntegerComparison);
        IntegerComparison cmp = (IntegerComparison) c.getRightOperand();
        int value = ((Number) c.getLeftOperand().getConcreteValue()).intValue();
        Comparator op = c.getComparator();
        Expression<Long> cmp_left = cmp.getLeftOperant();
        Expression<Long> cmp_right = cmp.getRightOperant();
        Comparator swap_op = op.swap();
        int swap_value = -value;
        return createIntegerConstraint(cmp_left, swap_op, cmp_right, swap_value);
    }
}
Also used : IntegerComparison(org.evosuite.symbolic.expr.bv.IntegerComparison) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) StringConstraint(org.evosuite.symbolic.expr.StringConstraint) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) Comparator(org.evosuite.symbolic.expr.Comparator)

Example 12 with Comparator

use of org.evosuite.symbolic.expr.Comparator in project evosuite by EvoSuite.

the class ConstraintToZ3Visitor method visit.

@Override
public SmtExpr visit(IntegerConstraint c, Void arg) {
    ExprToZ3Visitor v = new ExprToZ3Visitor();
    SmtExpr left = c.getLeftOperand().accept(v, null);
    SmtExpr right = c.getRightOperand().accept(v, null);
    if (left == null || right == null) {
        return null;
    }
    Comparator cmp = c.getComparator();
    return mkComparison(left, cmp, right);
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) Comparator(org.evosuite.symbolic.expr.Comparator)

Aggregations

Comparator (org.evosuite.symbolic.expr.Comparator)12 SmtExpr (org.evosuite.symbolic.solver.smt.SmtExpr)6 Constraint (org.evosuite.symbolic.expr.Constraint)2 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)2 RealConstraint (org.evosuite.symbolic.expr.RealConstraint)2 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 BranchCondition (org.evosuite.symbolic.BranchCondition)1 IntegerComparison (org.evosuite.symbolic.expr.bv.IntegerComparison)1 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)1 RealComparison (org.evosuite.symbolic.expr.bv.RealComparison)1 StringComparison (org.evosuite.symbolic.expr.bv.StringComparison)1 TestChromosome (org.evosuite.testcase.TestChromosome)1