Search in sources :

Example 46 with Constraint

use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.

the class DefaultTestCaseConcolicExecutor method execute.

public static Collection<Constraint<?>> execute(DefaultTestCase tc) {
    List<BranchCondition> pc = getPathCondition(tc);
    Collection<Constraint<?>> constraints = new LinkedList<Constraint<?>>();
    for (BranchCondition condition : pc) {
        constraints.addAll(condition.getSupportingConstraints());
        Constraint<?> constraint = condition.getConstraint();
        constraints.add(constraint);
    }
    return constraints;
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) BranchCondition(org.evosuite.symbolic.BranchCondition) LinkedList(java.util.LinkedList)

Example 47 with Constraint

use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.

the class TestSolverFloats method testExp.

public static void testExp(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestCaseExp();
    Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
    Map<String, Object> solution = solve(solver, constraints);
    assertNotNull(solution);
    Double var0 = (Double) solution.get("var0");
    Double var1 = (Double) solution.get("var1");
    assertEquals(var0.doubleValue(), Math.exp(var1.doubleValue()), DELTA);
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 48 with Constraint

use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.

the class TestSolverFloats method testRound.

public static void testRound(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestCaseRound();
    Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
    Map<String, Object> solution = solve(solver, constraints);
    assertNotNull(solution);
    Integer var0 = (Integer) solution.get("var0");
    Double var1 = (Double) solution.get("var1");
    assertEquals(var0.intValue(), Math.round(var1.doubleValue()));
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 49 with Constraint

use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.

the class TestSolverFloats method testAtan2.

public static void testAtan2(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestCaseAtan2();
    Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
    Map<String, Object> solution = solve(solver, constraints);
    assertNotNull(solution);
    Double var0 = (Double) solution.get("var0");
    Double var1 = (Double) solution.get("var1");
    Double var2 = (Double) solution.get("var2");
    assertEquals(var0.doubleValue(), Math.atan2(var1.doubleValue(), var2.doubleValue()), DELTA);
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 50 with Constraint

use of org.evosuite.symbolic.expr.Constraint in project evosuite by EvoSuite.

the class TestSolverFloats method testDiv.

public static void testDiv(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestCaseFloatDiv();
    Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
    Map<String, Object> solution = solve(solver, constraints);
    assertNotNull(solution);
    Double var0 = (Double) solution.get("var0");
    Double var1 = (Double) solution.get("var1");
    assertTrue(var0.doubleValue() == var1.doubleValue() / 2.0);
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Aggregations

Constraint (org.evosuite.symbolic.expr.Constraint)210 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)101 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)83 Test (org.junit.Test)81 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)76 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)75 ArrayList (java.util.ArrayList)68 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)42 SolverResult (org.evosuite.symbolic.solver.SolverResult)36 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)34 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)33 TestCaseStringAppendString (com.examples.with.different.packagename.solver.TestCaseStringAppendString)28 TestCaseStringIndexOfString (com.examples.with.different.packagename.solver.TestCaseStringIndexOfString)28 TestCaseStringLastIndexOfString (com.examples.with.different.packagename.solver.TestCaseStringLastIndexOfString)28 RealConstraint (org.evosuite.symbolic.expr.RealConstraint)26 IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)26 RealVariable (org.evosuite.symbolic.expr.fp.RealVariable)23 StringConstant (org.evosuite.symbolic.expr.str.StringConstant)22 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)17 RealConstant (org.evosuite.symbolic.expr.fp.RealConstant)16