use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class Pattern_Matches method executeFunction.
@Override
public Object executeFunction() {
// argument 0
String regex_str = (String) this.getConcArgument(0);
ReferenceConstant regex_ref = (ReferenceConstant) this.getSymbArgument(0);
// argument 1
CharSequence input_char_seq = (CharSequence) this.getConcArgument(1);
ReferenceExpression input_ref = this.getSymbArgument(1);
// return value
boolean res = this.getConcBooleanRetVal();
// symbolic execution
StringValue symb_regex = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, regex_str, regex_ref, regex_str);
StringValue symb_input = getSymbInput(input_char_seq, input_ref);
if (symb_input != null && symb_input.containsSymbolicVariable()) {
int concrete_value = res ? 1 : 0;
StringBinaryComparison strComp = new StringBinaryComparison(symb_regex, Operator.PATTERNMATCHES, symb_input, (long) concrete_value);
return strComp;
} else {
return this.getSymbIntegerRetVal();
}
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class CharAt method executeFunction.
@Override
public Object executeFunction() {
String conc_str = (String) this.getConcReceiver();
ReferenceConstant symb_str = this.getSymbReceiver();
StringValue string_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, symb_str, conc_str);
IntegerValue index_expr = this.getSymbIntegerArgument(0);
char res = this.getConcCharRetVal();
if (string_expr.containsSymbolicVariable() || index_expr.containsSymbolicVariable()) {
StringBinaryToIntegerExpression strBExpr = new StringBinaryToIntegerExpression(string_expr, Operator.CHARAT, index_expr, (long) res);
return strBExpr;
} else {
return this.getSymbIntegerRetVal();
}
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class Contains method executeFunction.
@Override
public Object executeFunction() {
String conc_left = (String) this.getConcReceiver();
ReferenceConstant symb_left = this.getSymbReceiver();
StringValue left_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_left, symb_left, conc_left);
CharSequence conc_right = (CharSequence) this.getConcArgument(0);
ReferenceConstant symb_right = (ReferenceConstant) this.getSymbArgument(0);
if (conc_right instanceof String) {
String conc_right_str = (String) conc_right;
StringValue right_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_right_str, symb_right, conc_right_str);
boolean res = this.getConcBooleanRetVal();
if (right_expr != null) {
if (left_expr.containsSymbolicVariable() || right_expr.containsSymbolicVariable()) {
int concrete_value = res ? 1 : 0;
StringBinaryComparison strComp = new StringBinaryComparison(left_expr, Operator.CONTAINS, right_expr, (long) concrete_value);
return strComp;
}
}
}
return this.getSymbIntegerRetVal();
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class Equals method executeFunction.
@Override
public Object executeFunction() {
String conc_left = (String) this.getConcReceiver();
ReferenceConstant symb_left = this.getSymbReceiver();
Object conc_right = this.getConcArgument(0);
ReferenceExpression symb_right = this.getSymbArgument(0);
boolean res = this.getConcBooleanRetVal();
StringValue left_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_left, symb_left, conc_left);
if (symb_right instanceof ReferenceConstant && conc_right instanceof String) {
ReferenceConstant non_null_symb_right = (ReferenceConstant) symb_right;
String conc_right_str = (String) conc_right;
StringValue right_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_right_str, non_null_symb_right, conc_right_str);
if (left_expr.containsSymbolicVariable() || right_expr.containsSymbolicVariable()) {
int conV = res ? 1 : 0;
StringBinaryComparison strBExpr = new StringBinaryComparison(left_expr, Operator.EQUALS, right_expr, (long) conV);
return strBExpr;
}
}
return this.getSymbIntegerRetVal();
}
use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.
the class Concat method executeFunction.
@Override
public Object executeFunction() {
String conc_left = (String) this.getConcReceiver();
ReferenceConstant symb_left = this.getSymbReceiver();
StringValue left_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_left, symb_left, conc_left);
String conc_right = (String) this.getConcArgument(0);
ReferenceConstant symb_right = (ReferenceConstant) this.getSymbArgument(0);
StringValue right_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_right, symb_right, conc_right);
String res = (String) this.getConcRetVal();
if (res != null) {
StringBinaryExpression symb_value = new StringBinaryExpression(left_expr, Operator.CONCAT, right_expr, (String) res);
ReferenceConstant symb_receiver = (ReferenceConstant) env.topFrame().operandStack.peekRef();
String conc_receiver = (String) res;
env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_receiver, symb_value);
}
return this.getSymbRetVal();
}
Aggregations