use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class SymbolicHeap method getStaticField.
public StringValue getStaticField(String owner, String name, String conc_value) {
FieldKey k = new FieldKey(owner, name);
StringValue symb_value = (StringValue) symb_static_fields.get(k);
if (symb_value == null || !((String) symb_value.getConcreteValue()).equals(conc_value)) {
symb_value = ExpressionFactory.buildNewStringConstant(conc_value);
symb_static_fields.remove(k);
}
return symb_value;
}
use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class Matcher_Matches method executeFunction.
@Override
public Object executeFunction() {
Matcher conc_matcher = (Matcher) this.getConcReceiver();
ReferenceConstant symb_matcher = (ReferenceConstant) this.getSymbReceiver();
boolean res = this.getConcBooleanRetVal();
String conc_regex = conc_matcher.pattern().pattern();
StringValue symb_input = (StringValue) env.heap.getField(Types.JAVA_UTIL_REGEX_MATCHER, SymbolicHeap.$MATCHER_INPUT, conc_matcher, symb_matcher);
if (symb_input != null && symb_input.containsSymbolicVariable()) {
int concrete_value = res ? 1 : 0;
StringConstant symb_regex = ExpressionFactory.buildNewStringConstant(conc_regex);
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.str.StringValue in project evosuite by EvoSuite.
the class Pattern_Matches method getSymbInput.
private StringValue getSymbInput(CharSequence input_char_seq, ReferenceExpression input_ref) {
StringValue symb_input;
if (input_ref instanceof ReferenceConstant) {
ReferenceConstant input_str_ref = (ReferenceConstant) input_ref;
assert input_char_seq != null;
if (input_char_seq instanceof String) {
String string = (String) input_char_seq;
symb_input = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, string, input_str_ref, string);
} else if (input_char_seq instanceof StringBuilder) {
StringBuilder stringBuffer = (StringBuilder) input_char_seq;
symb_input = env.heap.getField(Types.JAVA_LANG_STRING_BUILDER, SymbolicHeap.$STRING_BUILDER_CONTENTS, stringBuffer, input_str_ref, stringBuffer.toString());
} else {
symb_input = null;
}
} else {
symb_input = null;
}
return symb_input;
}
use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class CompareToIgnoreCase 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);
int res = this.getConcIntRetVal();
if (left_expr.containsSymbolicVariable() || right_expr.containsSymbolicVariable()) {
StringBinaryToIntegerExpression strBExpr = new StringBinaryToIntegerExpression(left_expr, Operator.COMPARETOIGNORECASE, right_expr, (long) res);
return strBExpr;
} else {
return this.getSymbIntegerRetVal();
}
}
use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class Pattern_Matcher method executeFunction.
@Override
public Object executeFunction() {
// receiver
@SuppressWarnings("unused") ReferenceConstant symb_receiver = this.getSymbReceiver();
// argument
CharSequence conc_char_seq = (CharSequence) this.getConcArgument(0);
ReferenceExpression symb_char_seq = this.getSymbArgument(0);
// return value
Matcher conc_matcher = (Matcher) this.getConcRetVal();
ReferenceConstant symb_matcher = (ReferenceConstant) this.getSymbRetVal();
if (conc_char_seq != null && conc_char_seq instanceof String) {
assert symb_char_seq instanceof ReferenceConstant;
ReferenceConstant symb_string = (ReferenceConstant) symb_char_seq;
String string = (String) conc_char_seq;
StringValue symb_input = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, string, symb_string, string);
env.heap.putField(Types.JAVA_UTIL_REGEX_MATCHER, SymbolicHeap.$MATCHER_INPUT, conc_matcher, symb_matcher, symb_input);
}
return symb_matcher;
}
Aggregations