use of org.evosuite.symbolic.expr.Comparator 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);
}
use of org.evosuite.symbolic.expr.Comparator in project evosuite by EvoSuite.
the class ConstraintToZ3Visitor method visit.
@Override
public SmtExpr visit(RealConstraint 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();
SmtExpr boolExpr = mkComparison(left, cmp, right);
return boolExpr;
}
use of org.evosuite.symbolic.expr.Comparator in project evosuite by EvoSuite.
the class DeprecatedTestSuiteDSE method calculateUncoveredBranches.
/**
* Iterate over path constraints to identify those which map to branches
* that are only covered one way
*/
private void calculateUncoveredBranches() {
unsolvedBranchConditions.clear();
if (Properties.DSE_NEGATE_ALL_CONDITIONS == true) {
for (TestChromosome testChromosome : pathConditions.keySet()) {
final List<BranchCondition> pathCondition = pathConditions.get(testChromosome);
for (BranchCondition branch : pathCondition) {
if (!unsolvableBranchConditions.contains(branch)) {
unsolvedBranchConditions.add(new TestBranchPair(testChromosome, pathCondition, branch));
}
}
}
} else {
Map<String, Map<Comparator, Set<TestBranchPair>>> solvedConstraints = new HashMap<String, Map<Comparator, Set<TestBranchPair>>>();
for (TestChromosome test : pathConditions.keySet()) {
final List<BranchCondition> pathCondition = pathConditions.get(test);
for (BranchCondition branch : pathCondition) {
if (unsolvableBranchConditions.contains(branch))
continue;
String index = getBranchIndex(branch);
if (!solvedConstraints.containsKey(index))
solvedConstraints.put(index, new HashMap<Comparator, Set<TestBranchPair>>());
Constraint<?> c = branch.getConstraint();
if (!solvedConstraints.get(index).containsKey(c.getComparator()))
solvedConstraints.get(index).put(c.getComparator(), new HashSet<TestBranchPair>());
solvedConstraints.get(index).get(c.getComparator()).add(new TestBranchPair(test, pathCondition, branch));
}
}
for (String index : solvedConstraints.keySet()) {
if (solvedConstraints.get(index).size() == 1) {
Set<TestBranchPair> branches = solvedConstraints.get(index).values().iterator().next();
unsolvedBranchConditions.addAll(branches);
}
}
logger.info("Update set of unsolved branch conditions to " + unsolvedBranchConditions.size());
if (Properties.DSE_RANK_BRANCH_CONDITIONS == false) {
Randomness.shuffle((ArrayList<TestBranchPair>) unsolvedBranchConditions);
}
}
}
use of org.evosuite.symbolic.expr.Comparator in project evosuite by EvoSuite.
the class ConstraintToZ3Str2Visitor method visit.
@Override
public SmtExpr visit(IntegerConstraint c, Void arg) {
ExprToZ3Str2Visitor v = new ExprToZ3Str2Visitor();
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);
}
use of org.evosuite.symbolic.expr.Comparator in project evosuite by EvoSuite.
the class ConstraintToZ3Str2Visitor method visit.
@Override
public SmtExpr visit(StringConstraint c, Void arg) {
ExprToZ3Str2Visitor v = new ExprToZ3Str2Visitor();
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);
}
Aggregations