|
|
@ -14,6 +14,7 @@ import org.hamcrest.Description;
|
|
|
|
import org.hamcrest.Matcher;
|
|
|
|
import org.hamcrest.Matcher;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.Vector;
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
|
|
|
|
import utils.InferError;
|
|
|
|
import utils.InferError;
|
|
|
@ -23,12 +24,15 @@ public class ResultContainsLineNumbers extends BaseMatcher<InferResults> {
|
|
|
|
|
|
|
|
|
|
|
|
private int[] lines;
|
|
|
|
private int[] lines;
|
|
|
|
private boolean strict;
|
|
|
|
private boolean strict;
|
|
|
|
|
|
|
|
private Optional<String> bugType;
|
|
|
|
|
|
|
|
|
|
|
|
public ResultContainsLineNumbers(
|
|
|
|
public ResultContainsLineNumbers(
|
|
|
|
int[] lines,
|
|
|
|
int[] lines,
|
|
|
|
boolean strict) {
|
|
|
|
boolean strict,
|
|
|
|
|
|
|
|
String bugType) {
|
|
|
|
this.lines = lines;
|
|
|
|
this.lines = lines;
|
|
|
|
this.strict = strict;
|
|
|
|
this.strict = strict;
|
|
|
|
|
|
|
|
this.bugType = Optional.ofNullable(bugType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -41,7 +45,9 @@ public class ResultContainsLineNumbers extends BaseMatcher<InferResults> {
|
|
|
|
for (int line : lines) {
|
|
|
|
for (int line : lines) {
|
|
|
|
boolean isContained = false;
|
|
|
|
boolean isContained = false;
|
|
|
|
for (InferError error : errors) {
|
|
|
|
for (InferError error : errors) {
|
|
|
|
isContained = isContained || line == error.getErrorLine();
|
|
|
|
String bugType = this.bugType.orElse(error.getErrorType());
|
|
|
|
|
|
|
|
boolean isSameErrType = bugType.equals(error.getErrorType());
|
|
|
|
|
|
|
|
isContained = isContained || (line == error.getErrorLine() && isSameErrType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
allContained = allContained && isContained;
|
|
|
|
allContained = allContained && isContained;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -65,11 +71,19 @@ public class ResultContainsLineNumbers extends BaseMatcher<InferResults> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static <T> Matcher<InferResults> containsLines(int[] lines) {
|
|
|
|
public static <T> Matcher<InferResults> containsLines(int[] lines) {
|
|
|
|
return new ResultContainsLineNumbers(lines, false);
|
|
|
|
return new ResultContainsLineNumbers(lines, false, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static <T> Matcher<InferResults> containsOnlyLines(int[] lines) {
|
|
|
|
public static <T> Matcher<InferResults> containsOnlyLines(int[] lines) {
|
|
|
|
return new ResultContainsLineNumbers(lines, true);
|
|
|
|
return new ResultContainsLineNumbers(lines, true, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static <T> Matcher<InferResults> containsLinesOfError(int[] lines, String bugType) {
|
|
|
|
|
|
|
|
return new ResultContainsLineNumbers(lines, false, bugType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static <T> Matcher<InferResults> containsOnlyLinesOfError(int[] lines, String bugType) {
|
|
|
|
|
|
|
|
return new ResultContainsLineNumbers(lines, true, bugType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int[] findLineNumbersInReport(InferResults results) {
|
|
|
|
private int[] findLineNumbersInReport(InferResults results) {
|
|
|
|