use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.
the class TestConstraintSolver method executeSolver.
private SolverResult executeSolver(List<BranchCondition> branch_conditions) throws SolverTimeoutException, SolverEmptyQueryException {
final int lastBranchIndex = branch_conditions.size() - 1;
BranchCondition last_branch = branch_conditions.get(lastBranchIndex);
List<Constraint<?>> constraints = new LinkedList<Constraint<?>>();
for (int i = 0; i < lastBranchIndex; i++) {
BranchCondition c = branch_conditions.get(i);
constraints.addAll(c.getSupportingConstraints());
constraints.add(c.getConstraint());
}
constraints.addAll(last_branch.getSupportingConstraints());
Constraint<?> lastConstraint = last_branch.getConstraint();
Constraint<?> targetConstraint = lastConstraint.negate();
constraints.add(targetConstraint);
System.out.println("Target constraints");
printConstraints(constraints);
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
if (solverResult.isUNSAT())
System.out.println("No new model was found");
else {
Map<String, Object> model = solverResult.getModel();
System.out.println(model.toString());
}
return solverResult;
}
use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.
the class TestSolverBitwise method testShiftLeft.
public static Map<String, Object> testShiftLeft(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
DefaultTestCase tc = buildTestCaseShiftLeft();
Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
Map<String, Object> solution = solve(solver, constraints);
return solution;
}
use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.
the class TestSolverBitwise method testBitOr.
public static Map<String, Object> testBitOr(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
DefaultTestCase tc = buildTestCaseBitOr();
Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
Map<String, Object> solution = solve(solver, constraints);
return solution;
}
use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.
the class TestSolverMath method testMin.
public static void testMin(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
DefaultTestCase tc = buildTestCaseMin();
Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
Map<String, Object> solution = solve(solver, constraints);
assertNotNull(solution);
Long var0 = (Long) solution.get("var0");
Long var1 = (Long) solution.get("var1");
assertEquals(10, Math.min(var0.intValue(), var1.intValue()));
}
use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.
the class TestSolverMath method testMax.
public static void testMax(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
DefaultTestCase tc = buildTestCaseMax();
Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
Map<String, Object> solution = solve(solver, constraints);
assertNotNull(solution);
Long var0 = (Long) solution.get("var0");
Long var1 = (Long) solution.get("var1");
assertEquals(10, Math.max(var0.intValue(), var1.intValue()));
}
Aggregations