use of org.evosuite.symbolic.expr.token.HasMoreTokensExpr in project evosuite by EvoSuite.
the class StringAVM method getTokenDelimiters.
private static Set<StringValue> getTokenDelimiters(Collection<Constraint<?>> constraints) {
Set<StringValue> delimiters = new HashSet<StringValue>();
for (Constraint<?> constraint : constraints) {
if (constraint instanceof StringConstraint) {
StringConstraint stringConstraint = (StringConstraint) constraint;
if (stringConstraint.getLeftOperand() instanceof HasMoreTokensExpr) {
HasMoreTokensExpr hasMoreTokensExpr = (HasMoreTokensExpr) stringConstraint.getLeftOperand();
StringValue delimiter = hasMoreTokensExpr.getTokenizerExpr().getDelimiter();
delimiters.add(delimiter);
}
}
}
return delimiters;
}
use of org.evosuite.symbolic.expr.token.HasMoreTokensExpr in project evosuite by EvoSuite.
the class DistanceCalculator method visit.
@Override
public Object visit(StringConstraint n, Void arg) {
Expression<?> exprLeft = n.getLeftOperand();
Comparator cmpr = n.getComparator();
double distance = 0.0;
if (exprLeft instanceof StringBinaryComparison) {
StringBinaryComparison scTarget = (StringBinaryComparison) exprLeft;
distance = getStringDistance(scTarget);
log.debug("Calculating distance of constraint " + n);
} else if (exprLeft instanceof StringMultipleComparison) {
StringMultipleComparison scTarget = (StringMultipleComparison) exprLeft;
distance = getStringDistance(scTarget);
log.debug("Calculating distance of constraint " + n);
} else if (exprLeft instanceof HasMoreTokensExpr) {
HasMoreTokensExpr hasMoreTokensExpr = (HasMoreTokensExpr) exprLeft;
distance = getStringDistance(hasMoreTokensExpr);
log.debug("Calculating distance of constraint " + n);
} else {
assert (false) : "Invalid string comparison";
}
assert (((Long) n.getRightOperand().getConcreteValue()).intValue() == 0);
if (cmpr == Comparator.NE) {
return distance;
} else {
// if not satisfied Long.MAX_VALUE else
return distance > 0 ? 0.0 : Double.MAX_VALUE;
}
}
use of org.evosuite.symbolic.expr.token.HasMoreTokensExpr in project evosuite by EvoSuite.
the class HasMoreTokens method executeFunction.
@Override
public Object executeFunction() {
StringTokenizer conc_tokenizer = (StringTokenizer) this.getConcReceiver();
ReferenceConstant symb_tokenizer = this.getSymbReceiver();
boolean res = this.getConcBooleanRetVal();
TokenizerExpr tokenizerExpr = (TokenizerExpr) env.heap.getField(Types.JAVA_UTIL_STRING_TOKENIZER, SymbolicHeap.$STRING_TOKENIZER_VALUE, conc_tokenizer, symb_tokenizer);
if (tokenizerExpr != null && tokenizerExpr.containsSymbolicVariable()) {
HasMoreTokensExpr hasMoreTokenExpr = new HasMoreTokensExpr(tokenizerExpr, (long) (res ? 1L : 0L));
return hasMoreTokenExpr;
}
return this.getSymbIntegerRetVal();
}
Aggregations