Search in sources :

Example 21 with Constraint

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

the class TestSolverSimpleMath method testCastIntToReal.

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

Example 22 with Constraint

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

the class TestSolverSimpleMath method testMul.

public static void testMul(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestCaseMul();
    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");
    assertTrue(var0.intValue() != 0);
    assertEquals(var1.intValue(), var0.intValue() * 2);
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 23 with Constraint

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

the class TestSolverSimpleMath method testEq.

public static void testEq(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestCaseEq();
    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(var0.intValue(), var1.intValue());
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 24 with Constraint

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

the class TestSolverSimpleMath method testLte.

public static void testLte(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestCaseLte();
    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");
    assertTrue(var0.intValue() <= var1.intValue());
}
Also used : Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase)

Example 25 with Constraint

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

the class StringAVMTests method testSimpleRegexThreeDigits.

@Test
public void testSimpleRegexThreeDigits() throws SolverTimeoutException {
    String name = "foo";
    StringVariable var = new StringVariable(name, "");
    String format = "\\d\\d\\d";
    List<Constraint<?>> constraints = getPatternConstraint(var, format);
    long start_time = System.currentTimeMillis();
    long timeout = Properties.DSE_CONSTRAINT_SOLVER_TIMEOUT_MILLIS;
    StringAVM avm = new StringAVM(var, constraints, start_time, timeout);
    boolean succeded = avm.applyAVM();
    assertTrue(succeded);
    String result = var.getConcreteValue();
    Integer value = Integer.parseInt(result);
    assertTrue("Value=" + result, value >= 0 && value <= 999);
}
Also used : StringConstraint(org.evosuite.symbolic.expr.StringConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) StringVariable(org.evosuite.symbolic.expr.str.StringVariable) StringAVM(org.evosuite.symbolic.solver.avm.StringAVM) Test(org.junit.Test)

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