use of org.evosuite.symbolic.solver.SolverResult in project evosuite by EvoSuite.
the class TestIntegerSearch method testEvosuiteExample4_1.
@Test
public void testEvosuiteExample4_1() throws SolverEmptyQueryException {
IntegerVariable var24 = new IntegerVariable("var24", 21458, Integer.MIN_VALUE, Integer.MAX_VALUE);
IntegerVariable var10 = new IntegerVariable("var10", 1172, Integer.MIN_VALUE, Integer.MAX_VALUE);
IntegerVariable var14 = new IntegerVariable("var14", -1903, Integer.MIN_VALUE, Integer.MAX_VALUE);
IntegerConstant c_19072 = new IntegerConstant(19072);
IntegerConstant c_11060 = new IntegerConstant(11060);
IntegerValue left = mul(sub(var24, div(var10, var14)), c_19072);
IntegerValue right = c_11060;
IntegerConstraint constr = new IntegerConstraint(left, Comparator.LT, right);
List<Constraint<?>> constraints = Collections.<Constraint<?>>singletonList(constr);
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
int v_24 = ((Number) model.get("var24")).intValue();
int v_10 = ((Number) model.get("var10")).intValue();
int v_14 = ((Number) model.get("var14")).intValue();
assertTrue((v_24 - (v_10 / v_14) * 19072) < 11060);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.SolverResult in project evosuite by EvoSuite.
the class TestIntegerSearch method testEvosuiteExample6.
@Test
public void testEvosuiteExample6() throws SolverEmptyQueryException {
Properties.DSE_VARIABLE_RESETS = 3;
// Cnstr 0 : var2__SYM(1890) >= 0 dist: 682.3333333333334
// Cnstr 1 : var1__SYM(-157) <= 0 dist: 682.3333333333334
// Cnstr 2 : var2__SYM(1890) <= var1__SYM(-157) dist: 682.3333333333334
// y >= 0
// x <= 0
// y <= x
int x = -157;
int y = 1890;
// TestSuiteDSE.setStart();
// int x = 879254357;
// int y = 1013652704;
IntegerVariable ivar1 = new IntegerVariable("test1", x, Integer.MIN_VALUE, Integer.MAX_VALUE);
IntegerVariable ivar2 = new IntegerVariable("test2", y, Integer.MIN_VALUE, Integer.MAX_VALUE);
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(ivar2, Comparator.GE, new IntegerConstant(0)));
constraints.add(new IntegerConstraint(ivar1, Comparator.LE, new IntegerConstant(0)));
constraints.add(new IntegerConstraint(ivar2, Comparator.LE, ivar1));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
if (model.containsKey("test1"))
x = ((Number) model.get("test1")).intValue();
if (model.containsKey("test2"))
y = ((Number) model.get("test2")).intValue();
assertTrue(y >= 0);
assertTrue(x <= 0);
assertTrue(y <= x);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.SolverResult in project evosuite by EvoSuite.
the class TestIntegerSearch method testNEArithmetic.
@Test
public void testNEArithmetic() throws SolverEmptyQueryException {
int var1 = 2;
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.NE, 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.SolverResult in project evosuite by EvoSuite.
the class TestIntegerSearch method testLTConstant.
@Test
public void testLTConstant() throws SolverEmptyQueryException {
// TODO: Currently, the model returned by the search is null if the
// constraint is already satisfied,
// so in this example the concrete value has to be the target initially
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(new IntegerVariable("test1", 235086, -1000000, 1000000), Comparator.LT, new IntegerConstant(235082)));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
assertNotNull(model.get("test1"));
assertTrue(235082 > ((Number) model.get("test1")).intValue());
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.solver.SolverResult in project evosuite by EvoSuite.
the class TestIntegerSearch method testLEConstant.
@Test
public void testLEConstant() throws SolverEmptyQueryException {
// TODO: Currently, the model returned by the search is null if the
// constraint is already satisfied,
// so in this example the concrete value has to be the target initially
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(new IntegerConstraint(new IntegerVariable("test1", 235086, -1000000, 1000000), Comparator.LE, new IntegerConstant(235082)));
try {
EvoSuiteSolver solver = new EvoSuiteSolver();
SolverResult solverResult = solver.solve(constraints);
assertTrue(solverResult.isSAT());
Map<String, Object> model = solverResult.getModel();
assertNotNull(model.get("test1"));
assertTrue(235082 >= ((Number) model.get("test1")).intValue());
} catch (SolverTimeoutException e) {
fail();
}
}
Aggregations