Search in sources :

Example 26 with StringConstant

use of org.evosuite.symbolic.expr.str.StringConstant in project evosuite by EvoSuite.

the class TestStringSearch method testStartsWithTrueConstant.

@Test
public void testStartsWithTrueConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    String var1 = "foo";
    String const2 = "test";
    StringVariable strVar = new StringVariable("test1", var1);
    StringConstant strConst = new StringConstant(const2);
    IntegerConstant offs_expr = new IntegerConstant(2);
    ArrayList<Expression<?>> other = new ArrayList<Expression<?>>();
    other.add(offs_expr);
    StringMultipleComparison strComp = new StringMultipleComparison(strVar, Operator.STARTSWITH, strConst, other, 0L);
    constraints.add(new StringConstraint(strComp, Comparator.NE, new IntegerConstant(0)));
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        assertNotNull(result.get("test1"));
        assertTrue((result.get("test1").toString()).startsWith(const2, 2));
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) StringMultipleComparison(org.evosuite.symbolic.expr.bv.StringMultipleComparison) StringConstraint(org.evosuite.symbolic.expr.StringConstraint) StringConstraint(org.evosuite.symbolic.expr.StringConstraint) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) EvoSuiteSolver(org.evosuite.symbolic.solver.avm.EvoSuiteSolver) ArrayList(java.util.ArrayList) StringVariable(org.evosuite.symbolic.expr.str.StringVariable) IntegerConstant(org.evosuite.symbolic.expr.bv.IntegerConstant) Expression(org.evosuite.symbolic.expr.Expression) StringBinaryToIntegerExpression(org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression) StringUnaryExpression(org.evosuite.symbolic.expr.str.StringUnaryExpression) StringConstant(org.evosuite.symbolic.expr.str.StringConstant) Test(org.junit.Test)

Aggregations

StringConstant (org.evosuite.symbolic.expr.str.StringConstant)26 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)23 Constraint (org.evosuite.symbolic.expr.Constraint)22 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)21 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)20 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)20 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)19 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)18 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)18 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)18 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)5 StringUnaryExpression (org.evosuite.symbolic.expr.str.StringUnaryExpression)5 Expression (org.evosuite.symbolic.expr.Expression)4 StringMultipleComparison (org.evosuite.symbolic.expr.bv.StringMultipleComparison)4 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)4 StringValue (org.evosuite.symbolic.expr.str.StringValue)4 Matcher (java.util.regex.Matcher)2 SolverResult (org.evosuite.symbolic.solver.SolverResult)2 Pattern (java.util.regex.Pattern)1