use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class ToUpperCase method executeFunction.
@Override
public Object executeFunction() {
// object receiver
ReferenceConstant symb_str = this.getSymbReceiver();
String conc_str = (String) this.getConcReceiver();
// return value
String conc_ret_val = (String) this.getConcRetVal();
ReferenceConstant symb_ret_val = (ReferenceConstant) this.getSymbRetVal();
StringValue string_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, symb_str, conc_str);
StringUnaryExpression symb_value = new StringUnaryExpression(string_expr, Operator.TOUPPERCASE, conc_ret_val);
env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_ret_val, symb_ret_val, symb_value);
return this.getSymbRetVal();
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class StringBuffer_SetLength method executeFunction.
@Override
public Object executeFunction() {
ReferenceConstant symb_str_buffer = this.getSymbReceiver();
StringBuffer conc_str_buffer = (StringBuffer) this.getConcReceiver();
IntegerValue newSymbLength = this.getSymbIntegerArgument(0);
int newConcLength = this.getConcIntArgument(0);
// retrieve symbolic value from heap
String conc_value = conc_str_buffer.toString();
StringValue symb_value = env.heap.getField(Types.JAVA_LANG_STRING_BUFFER, SymbolicHeap.$STRING_BUFFER_CONTENTS, conc_str_buffer, symb_str_buffer, pre_conc_value);
if (symb_value.containsSymbolicVariable() || newSymbLength.containsSymbolicVariable()) {
StringValue new_symb_value = null;
if (!newSymbLength.containsSymbolicVariable() && newConcLength == 0) {
// StringBuffer contents equals to "" string
new_symb_value = new StringConstant("");
} else {
// StringBuffer contents equ
new_symb_value = new StringMultipleExpression(symb_value, Operator.SUBSTRING, new IntegerConstant(0), new ArrayList<Expression<?>>(Collections.singletonList(newSymbLength)), conc_value);
}
env.heap.putField(Types.JAVA_LANG_STRING_BUFFER, SymbolicHeap.$STRING_BUFFER_CONTENTS, conc_str_buffer, symb_str_buffer, new_symb_value);
}
// return void
return null;
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class BigInteger_IntValue method executeFunction.
@Override
public Object executeFunction() {
BigInteger conc_big_integer = (BigInteger) this.getConcReceiver();
ReferenceConstant symb_big_integer = this.getSymbReceiver();
int res = this.getConcIntRetVal();
IntegerValue integer_expr = this.env.heap.getField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_big_integer, symb_big_integer, res);
return integer_expr;
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class Length method executeFunction.
@Override
public Object executeFunction() {
ReferenceConstant symb_str = this.getSymbReceiver();
String conc_str = (String) this.getConcReceiver();
int res = this.getConcIntRetVal();
StringValue string_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, symb_str, conc_str);
if (string_expr.containsSymbolicVariable()) {
StringUnaryToIntegerExpression strUnExpr = new StringUnaryToIntegerExpression(string_expr, Operator.LENGTH, (long) res);
return strUnExpr;
}
return this.getSymbIntegerRetVal();
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class RegionMatches method executeFunction.
@Override
public Object executeFunction() {
ReferenceConstant symb_receiver = (ReferenceConstant) this.getSymbReceiver();
String conc_receiver = (String) this.getConcReceiver();
StringValue stringReceiverExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_receiver, conc_receiver);
IntegerValue ignoreCaseExpr = this.getSymbIntegerArgument(0);
IntegerValue toffsetExpr = this.getSymbIntegerArgument(1);
ReferenceConstant symb_other = (ReferenceConstant) this.getSymbArgument(2);
String conc_other = (String) this.getConcArgument(2);
StringValue otherExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_other, symb_other, conc_other);
IntegerValue ooffsetExpr = this.getSymbIntegerArgument(3);
IntegerValue lenExpr = this.getSymbIntegerArgument(4);
boolean res = this.getConcBooleanRetVal();
if (stringReceiverExpr.containsSymbolicVariable() || ignoreCaseExpr.containsSymbolicVariable() || toffsetExpr.containsSymbolicVariable() || otherExpr.containsSymbolicVariable() || ooffsetExpr.containsSymbolicVariable() || lenExpr.containsSymbolicVariable()) {
ArrayList<Expression<?>> other = new ArrayList<Expression<?>>();
other.add(toffsetExpr);
other.add(ooffsetExpr);
other.add(lenExpr);
other.add(ignoreCaseExpr);
int conV = res ? 1 : 0;
StringMultipleComparison strComp = new StringMultipleComparison(stringReceiverExpr, Operator.REGIONMATCHES, otherExpr, other, (long) conV);
return strComp;
}
return this.getSymbIntegerRetVal();
}
Aggregations