use of org.evosuite.symbolic.expr.IntegerConstraint in project evosuite by EvoSuite.
the class TestStringSearch method testChopOffIndexOfC.
@Test
public void testChopOffIndexOfC() {
String var1value = "D<E\u001Exqaa:saksajij1§n";
StringVariable var1 = new StringVariable("var1", var1value);
IntegerConstant colon_code = new IntegerConstant(58);
IntegerConstant minus_one = new IntegerConstant(-1);
int colon_int_code = (int) ':';
int concrete_value = var1value.indexOf(colon_int_code);
StringBinaryToIntegerExpression index_of_colon = new StringBinaryToIntegerExpression(var1, Operator.INDEXOFC, colon_code, (long) concrete_value);
IntegerConstraint constr1 = new IntegerConstraint(index_of_colon, Comparator.EQ, minus_one);
List<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(constr1);
EvoSuiteSolver solver = new EvoSuiteSolver();
Map<String, Object> solution;
try {
solution = solve(solver, constraints);
assertNotNull(solution);
} catch (SolverTimeoutException e) {
fail();
}
}
use of org.evosuite.symbolic.expr.IntegerConstraint in project evosuite by EvoSuite.
the class TestConstraintSolver1 method buildConstraintSystem.
private static Collection<Constraint<?>> buildConstraintSystem() {
StringVariable var0 = new StringVariable("var0", INIT_STRING);
StringUnaryToIntegerExpression length = new StringUnaryToIntegerExpression(var0, Operator.LENGTH, (long) INIT_STRING.length());
IntegerConstant const3 = new IntegerConstant(3);
StringBinaryToIntegerExpression charAt3 = new StringBinaryToIntegerExpression(var0, Operator.CHARAT, const3, (long) INIT_STRING.charAt(3));
IntegerConstant const4 = new IntegerConstant(4);
StringBinaryToIntegerExpression charAt4 = new StringBinaryToIntegerExpression(var0, Operator.CHARAT, const4, (long) INIT_STRING.charAt(4));
IntegerConstant const5 = new IntegerConstant(INIT_STRING.length());
IntegerConstant const95 = new IntegerConstant(EXPECTED_STRING.charAt(3));
IntegerConstant const43 = new IntegerConstant(EXPECTED_STRING.charAt(4));
IntegerConstraint constr1 = new IntegerConstraint(length, Comparator.EQ, const5);
IntegerConstraint constr2 = new IntegerConstraint(charAt3, Comparator.EQ, const95);
IntegerConstraint constr3 = new IntegerConstraint(charAt4, Comparator.EQ, const43);
return Arrays.<Constraint<?>>asList(constr1, constr2, constr3);
}
use of org.evosuite.symbolic.expr.IntegerConstraint in project evosuite by EvoSuite.
the class TestStringSearch3 method testCharAt.
// (var3("<V6h") charAt 0) >= 0,
// (var3("<V6h").length() - 1) >= 0,
// (var3("<V6h") charAt 0) == 10]
@Test
public void testCharAt() {
StringVariable var3 = new StringVariable("var3", "<\n V6h");
StringBinaryToIntegerExpression var3_charAt_0 = new StringBinaryToIntegerExpression(var3, Operator.CHARAT, new IntegerConstant(0), (long) "<\n V6h".charAt(0));
IntegerConstraint cnstr1 = new IntegerConstraint(var3_charAt_0, Comparator.GE, new IntegerConstant(0));
StringUnaryToIntegerExpression var3_length = new StringUnaryToIntegerExpression(var3, Operator.LENGTH, (long) "<\n V6h".length());
IntegerBinaryExpression length_minus_one = new IntegerBinaryExpression(var3_length, Operator.MINUS, new IntegerConstant(1), (long) "<\n V6h".length() - 1);
IntegerConstraint cnstr2 = new IntegerConstraint(length_minus_one, Comparator.GE, new IntegerConstant(0));
IntegerConstraint cnstr3 = new IntegerConstraint(var3_charAt_0, Comparator.EQ, new IntegerConstant(10));
ArrayList<Constraint<?>> constraints = new ArrayList<Constraint<?>>();
constraints.add(cnstr1);
constraints.add(cnstr2);
constraints.add(cnstr3);
EvoSuiteSolver solver = new EvoSuiteSolver();
Map<String, Object> solution;
try {
solution = solve(solver, constraints);
assertNotNull(solution);
} catch (SolverTimeoutException e) {
fail();
}
}
Aggregations