Search in sources :

Example 1 with StringAVM

use of org.evosuite.symbolic.solver.avm.StringAVM 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)

Example 2 with StringAVM

use of org.evosuite.symbolic.solver.avm.StringAVM in project evosuite by EvoSuite.

the class StringAVMTests method testIssueWithOptional.

@Test
public void testIssueWithOptional() throws SolverTimeoutException {
    String name = "addd";
    StringVariable var = new StringVariable(name, "");
    String format = "a.?c";
    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);
}
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)

Example 3 with StringAVM

use of org.evosuite.symbolic.solver.avm.StringAVM in project evosuite by EvoSuite.

the class StringAVMTests method testInsertLeft.

@Test
public void testInsertLeft() throws SolverTimeoutException {
    String name = "foo";
    String start = "abc";
    StringVariable var = new StringVariable(name, start);
    String format = "\\d\\d\\d" + start;
    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();
    assertTrue("Length=" + result.length(), result.length() == 6);
    assertTrue(result, result.endsWith(start));
}
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)

Example 4 with StringAVM

use of org.evosuite.symbolic.solver.avm.StringAVM in project evosuite by EvoSuite.

the class StringAVMTests method testInsertRight.

@Test
public void testInsertRight() throws SolverTimeoutException {
    String name = "foo";
    String start = "abc";
    StringVariable var = new StringVariable(name, start);
    String format = start + "\\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();
    assertTrue("Length=" + result.length(), result.length() == 6);
    assertTrue(result, result.startsWith(start));
}
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)4 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)4 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)4 StringAVM (org.evosuite.symbolic.solver.avm.StringAVM)4 Test (org.junit.Test)4