Search in sources :

Example 81 with Constraint

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

the class TestSolverStringFunctions method testStringLastIndexOfChar.

public static Map<String, Object> testStringLastIndexOfChar(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestLastIndexOfChar();
    Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
    Map<String, Object> solution = solve(solver, constraints);
    return solution;
}
Also used : IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) TestCaseStringAppendString(com.examples.with.different.packagename.solver.TestCaseStringAppendString) TestCaseStringLastIndexOfString(com.examples.with.different.packagename.solver.TestCaseStringLastIndexOfString) TestCaseStringIndexOfString(com.examples.with.different.packagename.solver.TestCaseStringIndexOfString)

Example 82 with Constraint

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

the class TestSolverStringFunctions method testStringUpperCase.

public static Map<String, Object> testStringUpperCase(Solver solver) throws SecurityException, NoSuchMethodException, SolverTimeoutException {
    DefaultTestCase tc = buildTestUpperCase();
    Collection<Constraint<?>> constraints = DefaultTestCaseConcolicExecutor.execute(tc);
    Map<String, Object> solution = solve(solver, constraints);
    return solution;
}
Also used : IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) TestCaseStringAppendString(com.examples.with.different.packagename.solver.TestCaseStringAppendString) TestCaseStringLastIndexOfString(com.examples.with.different.packagename.solver.TestCaseStringLastIndexOfString) TestCaseStringIndexOfString(com.examples.with.different.packagename.solver.TestCaseStringIndexOfString)

Example 83 with Constraint

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

the class TestSolverUNSAT method testUNSAT.

public static void testUNSAT(Solver solver) throws SolverTimeoutException, IOException, SolverParseException, SolverEmptyQueryException, SolverErrorException {
    Collection<Constraint<?>> constraints = new LinkedList<Constraint<?>>();
    IntegerVariable x = new IntegerVariable("x", 1L, Long.MIN_VALUE, Long.MAX_VALUE);
    IntegerConstraint unsat_constraint = ConstraintFactory.neq(x, x);
    constraints.add(unsat_constraint);
    SolverResult result = solver.solve(constraints);
    assertTrue(result.isUNSAT());
}
Also used : IntegerVariable(org.evosuite.symbolic.expr.bv.IntegerVariable) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) LinkedList(java.util.LinkedList)

Example 84 with Constraint

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

the class TestConstraintSolver3 method buildConstraintSystem.

private static Collection<Constraint<?>> buildConstraintSystem() {
    StringVariable var0 = new StringVariable("var0", INIT_STRING);
    StringToIntegerCast castStr = new StringToIntegerCast(var0, (long) Integer.parseInt(INIT_STRING));
    IntegerConstant const126 = new IntegerConstant(EXPECTED_INTEGER);
    IntegerConstraint constr1 = new IntegerConstraint(castStr, Comparator.EQ, const126);
    return Arrays.<Constraint<?>>asList(constr1);
}
Also used : IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) StringToIntegerCast(org.evosuite.symbolic.expr.bv.StringToIntegerCast) StringVariable(org.evosuite.symbolic.expr.str.StringVariable) IntegerConstant(org.evosuite.symbolic.expr.bv.IntegerConstant)

Example 85 with Constraint

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

the class TestIsInteger method testIsInteger.

@Test
public void testIsInteger() throws SolverEmptyQueryException {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    constraints.add(new IntegerConstraint(new StringUnaryToIntegerExpression(new StringVariable("var0", "hello"), Operator.IS_INTEGER, 0L), Comparator.NE, new IntegerConstant(0)));
    EvoSuiteSolver solver = new EvoSuiteSolver();
    try {
        SolverResult result = solver.solve(constraints);
        assertTrue(result.isSAT());
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) 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) StringUnaryToIntegerExpression(org.evosuite.symbolic.expr.bv.StringUnaryToIntegerExpression) StringVariable(org.evosuite.symbolic.expr.str.StringVariable) IntegerConstant(org.evosuite.symbolic.expr.bv.IntegerConstant) 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