use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver in project evosuite by EvoSuite.
the class TestIntegerSearch method testLEArithmetic.
@Test
public void testLEArithmetic() throws SolverEmptyQueryException {
int var1 = 3;
int var2 = 1;
int var3 = 1;
assertTrue(var1 > var2 + var3);
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(new IntegerVariable("test1", var1, -1000000, 1000000), Comparator.LE, new IntegerBinaryExpression(new IntegerVariable("test2", var2, -1000000, 1000000), Operator.PLUS, new IntegerVariable("test3", var3, -1000000, 1000000), 0L)));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
if (model.containsKey("test1"))
var1 = ((Number) model.get("test1")).intValue();
if (model.containsKey("test2"))
var2 = ((Number) model.get("test2")).intValue();
if (model.containsKey("test3"))
var3 = ((Number) model.get("test3")).intValue();
assertTrue(var1 <= var2 + var3);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver in project evosuite by EvoSuite.
the class TestIntegerSearch method testGEArithmetic.
@Test
public void testGEArithmetic() throws SolverEmptyQueryException {
int var1 = 0;
int var2 = 1;
int var3 = 1;
assertTrue(var1 < var2 + var3);
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(new IntegerVariable("test1", var1, -1000000, 1000000), Comparator.GT, new IntegerBinaryExpression(new IntegerVariable("test2", var2, -1000000, 1000000), Operator.PLUS, new IntegerVariable("test3", var3, -1000000, 1000000), 0L)));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
if (model.containsKey("test1"))
var1 = ((Number) model.get("test1")).intValue();
if (model.containsKey("test2"))
var2 = ((Number) model.get("test2")).intValue();
if (model.containsKey("test3"))
var3 = ((Number) model.get("test3")).intValue();
assertTrue(var1 >= var2 + var3);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver in project evosuite by EvoSuite.
the class TestIntegerSearch method testEQArithmetic.
@Test
public void testEQArithmetic() throws SolverEmptyQueryException {
int var1 = 0;
int var2 = 1;
int var3 = 1;
assertTrue(var1 != var2 + var3);
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(new IntegerVariable("test1", var1, -1000000, 1000000), Comparator.EQ, new IntegerBinaryExpression(new IntegerVariable("test2", var2, -1000000, 1000000), Operator.PLUS, new IntegerVariable("test3", var3, -1000000, 1000000), 0L)));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
if (model.containsKey("test1"))
var1 = ((Number) model.get("test1")).intValue();
if (model.containsKey("test2"))
var2 = ((Number) model.get("test2")).intValue();
if (model.containsKey("test3"))
var3 = ((Number) model.get("test3")).intValue();
assertTrue(var1 == var2 + var3);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver in project evosuite by EvoSuite.
the class TestIntegerSearch method testNEVariable.
@Test
public void testNEVariable() throws SolverEmptyQueryException {
int var1 = 1;
int var2 = 1;
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(new IntegerVariable("test1", var1, -1000000, 1000000), Comparator.NE, new IntegerVariable("test2", var2, -1000000, 1000000)));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
if (model.containsKey("test1"))
var1 = ((Number) model.get("test1")).intValue();
if (model.containsKey("test2"))
var2 = ((Number) model.get("test2")).intValue();
assertTrue(var1 != var2);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.avm.EvoSuiteSolver in project evosuite by EvoSuite.
the class TestRealSearch method testLTVariable.
@Test
public void testLTVariable() {
double var1 = 2.6576;
double var2 = 1.434;
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new RealConstraint(new RealVariable("test1", var1, -1000000.0, 1000000.0), Comparator.LT, new RealVariable("test2", var2, -1000000.0, 1000000.0)));
EvoSuiteSolver skr = new EvoSuiteSolver();
Map<String, Object> result;
try {
result = solve(skr, constraints);
assertNotNull(result);
if (result.containsKey("test1"))
var1 = ((Number) result.get("test1")).doubleValue();
if (result.containsKey("test2"))
var2 = ((Number) result.get("test2")).doubleValue();
assertTrue(var1 < var2);
} catch (SolverTimeoutException e) {
fail();
}
}
Aggregations