Search in sources :

Example 26 with StringBinaryComparison

use of org.evosuite.symbolic.expr.bv.StringBinaryComparison in project evosuite by EvoSuite.

the class TestStringSearch method testRegexMatchesFalse.

@Test
public void testRegexMatchesFalse() {
    List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
    String var1 = "testsomestring";
    String const2 = "testsomestring";
    StringVariable strVar = new StringVariable("test1", var1);
    StringConstant strConst = new StringConstant(const2);
    StringBinaryComparison strComp = new StringBinaryComparison(strVar, Operator.PATTERNMATCHES, 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 should not match TEST: " + result.get("test1").toString(), result.get("test1").toString().matches(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

StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)26 StringConstant (org.evosuite.symbolic.expr.str.StringConstant)20 Constraint (org.evosuite.symbolic.expr.Constraint)17 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)17 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)17 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)16 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)14 Test (org.junit.Test)14 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)13 ArrayList (java.util.ArrayList)12 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)12 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)8 StringValue (org.evosuite.symbolic.expr.str.StringValue)8 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)3 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)1 Pattern (org.apache.oro.text.regex.Pattern)1 StringMultipleComparison (org.evosuite.symbolic.expr.bv.StringMultipleComparison)1 StringUnaryExpression (org.evosuite.symbolic.expr.str.StringUnaryExpression)1 HasMoreTokensExpr (org.evosuite.symbolic.expr.token.HasMoreTokensExpr)1