Search in sources :

Example 31 with SolverTimeoutException

use of org.evosuite.symbolic.solver.SolverTimeoutException in project evosuite by EvoSuite.

the class TestStringSearch method testEqualsFalseConstant.

@Test
public void testEqualsFalseConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    String var1 = "foo";
    String const2 = "foo";
    StringVariable strVar = new StringVariable("test1", var1);
    StringConstant strConst = new StringConstant(const2);
    StringBinaryComparison strComp = new StringBinaryComparison(strVar, Operator.EQUALS, strConst, 0L);
    constraints.add(new StringConstraint(strComp, Comparator.EQ, new IntegerConstant(0)));
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        assertNotNull(result.get("test1"));
        assertTrue(!const2.equals(result.get("test1").toString()));
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) 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) StringBinaryComparison(org.evosuite.symbolic.expr.bv.StringBinaryComparison) StringConstant(org.evosuite.symbolic.expr.str.StringConstant) Test(org.junit.Test)

Example 32 with SolverTimeoutException

use of org.evosuite.symbolic.solver.SolverTimeoutException in project evosuite by EvoSuite.

the class TestStringSearch method testContainsTrueConstant.

@Test
public void testContainsTrueConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    String var1 = "foo";
    String const2 = "test";
    StringVariable strVar = new StringVariable("test1", var1);
    StringConstant strConst = new StringConstant(const2);
    StringBinaryComparison strComp = new StringBinaryComparison(strVar, Operator.CONTAINS, strConst, 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()).contains(const2));
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) 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) StringBinaryComparison(org.evosuite.symbolic.expr.bv.StringBinaryComparison) StringConstant(org.evosuite.symbolic.expr.str.StringConstant) Test(org.junit.Test)

Example 33 with SolverTimeoutException

use of org.evosuite.symbolic.solver.SolverTimeoutException in project evosuite by EvoSuite.

the class TestStringSearch method testEqualsIgnoreCaseFalseConstant.

@Test
public void testEqualsIgnoreCaseFalseConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    String var1 = "foo";
    String const2 = "FOO";
    StringVariable strVar = new StringVariable("test1", var1);
    StringConstant strConst = new StringConstant(const2);
    StringBinaryComparison strComp = new StringBinaryComparison(strVar, Operator.EQUALSIGNORECASE, strConst, 0L);
    constraints.add(new StringConstraint(strComp, Comparator.EQ, new IntegerConstant(0)));
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        assertNotNull(result.get("test1"));
        assertFalse(const2.equalsIgnoreCase(result.get("test1").toString()));
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) 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) StringBinaryComparison(org.evosuite.symbolic.expr.bv.StringBinaryComparison) StringConstant(org.evosuite.symbolic.expr.str.StringConstant) Test(org.junit.Test)

Example 34 with SolverTimeoutException

use of org.evosuite.symbolic.solver.SolverTimeoutException in project evosuite by EvoSuite.

the class TestStringSearch method testStartsWithFalseConstant.

@Test
public void testStartsWithFalseConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    String var1 = "footest";
    String const2 = "test";
    StringVariable strVar = new StringVariable("test1", var1);
    StringConstant strConst = new StringConstant(const2);
    IntegerConstant offs_expr = new IntegerConstant(3);
    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.EQ, new IntegerConstant(0)));
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        assertNotNull(result.get("test1"));
        assertFalse((result.get("test1").toString()).startsWith(const2, 3));
    } 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)

Example 35 with SolverTimeoutException

use of org.evosuite.symbolic.solver.SolverTimeoutException in project evosuite by EvoSuite.

the class TestStringSearch method testEndsWithFalseConstant.

@Test
public void testEndsWithFalseConstant() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    String var1 = "footest";
    String const2 = "test";
    StringVariable strVar = new StringVariable("test1", var1);
    StringConstant strConst = new StringConstant(const2);
    StringBinaryComparison strComp = new StringBinaryComparison(strVar, Operator.ENDSWITH, strConst, 0L);
    constraints.add(new StringConstraint(strComp, Comparator.EQ, new IntegerConstant(0)));
    EvoSuiteSolver skr = new EvoSuiteSolver();
    Map<String, Object> result;
    try {
        result = solve(skr, constraints);
        assertNotNull(result);
        assertNotNull(result.get("test1"));
        assertFalse((result.get("test1").toString()).endsWith(const2));
    } catch (SolverTimeoutException e) {
        fail();
    }
}
Also used : SolverTimeoutException(org.evosuite.symbolic.solver.SolverTimeoutException) 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) StringBinaryComparison(org.evosuite.symbolic.expr.bv.StringBinaryComparison) StringConstant(org.evosuite.symbolic.expr.str.StringConstant) Test(org.junit.Test)

Aggregations

SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)79 Constraint (org.evosuite.symbolic.expr.Constraint)75 Test (org.junit.Test)75 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)74 ArrayList (java.util.ArrayList)68 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)48 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)35 SolverResult (org.evosuite.symbolic.solver.SolverResult)34 IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)25 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)24 RealConstraint (org.evosuite.symbolic.expr.RealConstraint)22 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)22 RealVariable (org.evosuite.symbolic.expr.fp.RealVariable)22 StringConstant (org.evosuite.symbolic.expr.str.StringConstant)18 RealConstant (org.evosuite.symbolic.expr.fp.RealConstant)15 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)13 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)10 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)8 StringUnaryExpression (org.evosuite.symbolic.expr.str.StringUnaryExpression)5 Expression (org.evosuite.symbolic.expr.Expression)4