Search in sources :

Example 1 with StringComparison

use of org.evosuite.symbolic.expr.bv.StringComparison in project evosuite by EvoSuite.

the class ConstraintNormalizer method createStringConstraint.

private static Constraint<?> createStringConstraint(IntegerConstraint c) {
    if (c.getLeftOperand() instanceof StringComparison) {
        StringComparison string_comparison = (StringComparison) c.getLeftOperand();
        @SuppressWarnings("unchecked") Expression<Long> number_expr = (Expression<Long>) c.getRightOperand();
        IntegerConstant constant = new IntegerConstant(number_expr.getConcreteValue());
        return new StringConstraint(string_comparison, c.getComparator(), constant);
    } else {
        assert c.getRightOperand() instanceof StringComparison;
        StringComparison string_comparison = (StringComparison) c.getRightOperand();
        @SuppressWarnings("unchecked") Expression<Long> number_expr = (Expression<Long>) c.getLeftOperand();
        IntegerConstant constant = new IntegerConstant(number_expr.getConcreteValue());
        return new StringConstraint(string_comparison, c.getComparator(), constant);
    }
}
Also used : StringComparison(org.evosuite.symbolic.expr.bv.StringComparison) StringConstraint(org.evosuite.symbolic.expr.StringConstraint) Expression(org.evosuite.symbolic.expr.Expression) IntegerConstant(org.evosuite.symbolic.expr.bv.IntegerConstant)

Example 2 with StringComparison

use of org.evosuite.symbolic.expr.bv.StringComparison in project evosuite by EvoSuite.

the class ConstraintToZ3Visitor method visit.

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

Aggregations

IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)2 StringComparison (org.evosuite.symbolic.expr.bv.StringComparison)2 Comparator (org.evosuite.symbolic.expr.Comparator)1 Expression (org.evosuite.symbolic.expr.Expression)1 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)1 SmtExpr (org.evosuite.symbolic.solver.smt.SmtExpr)1