Search in sources :

Example 36 with IntegerVariable

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

the class TestIntegerSearch method testLTVariable.

@Test
public void testLTVariable() throws SolverEmptyQueryException {
    int var1 = 2;
    int var2 = 1;
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    constraints.add(new IntegerConstraint(new IntegerVariable("test1", var1, -1000000, 1000000), Comparator.LT, 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();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) SolverResult(org.evosuite.symbolic.solver.SolverResult) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) IntegerVariable(org.evosuite.symbolic.expr.bv.IntegerVariable) Test(org.junit.Test)

Aggregations

IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)36 Constraint (org.evosuite.symbolic.expr.Constraint)26 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)25 SolverResult (org.evosuite.symbolic.solver.SolverResult)25 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)25 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)24 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)22 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)12 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)7 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)6 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)6 EvosuiteError (org.evosuite.testcase.execution.EvosuiteError)6 VariableReference (org.evosuite.testcase.variable.VariableReference)6 RealVariable (org.evosuite.symbolic.expr.fp.RealVariable)4 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)4 LinkedList (java.util.LinkedList)2 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)2 HashSet (java.util.HashSet)1 Variable (org.evosuite.symbolic.expr.Variable)1