1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 05:45:58 +02:00

Fix compile error

This commit is contained in:
Alena Laskavaia 2010-05-17 16:33:34 +00:00
parent c039cc7cfc
commit 6892a28e3d

View file

@ -17,17 +17,21 @@ import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.IProblemReporter; import org.eclipse.cdt.codan.core.model.IProblemReporter;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
/** /**
* @author Alena * @author Alena
* *
*/ */
public class CheckerTestCase extends CodanTestCase { public class CheckerTestCase extends CodanTestCase {
private static final IProgressMonitor NullPM = new NullProgressMonitor();
private IMarker[] markers; private IMarker[] markers;
public void checkErrorLine(int i) { public void checkErrorLine(int i) {
checkErrorLine(currentFile, i); checkErrorLine(currentFile, i);
} }
/** /**
* @param i * @param i
* - line * - line
@ -54,18 +58,15 @@ public class CheckerTestCase extends CodanTestCase {
String mfile = m.getResource().getName(); String mfile = m.getResource().getName();
if (line.equals(i)) { if (line.equals(i)) {
found = true; found = true;
if (file!=null && !file.getName().equals(mfile)) if (file != null && !file.getName().equals(mfile)) found = false;
found = false; else break;
else
break;
} }
} }
assertTrue("Error on line " + i + " not found ", found); assertTrue("Error on line " + i + " not found ", found);
} }
public void checkNoErrors() { public void checkNoErrors() {
assertTrue("Found errors but should not", markers == null assertTrue("Found errors but should not", markers == null || markers.length == 0);
|| markers.length == 0);
} }
/** /**
@ -84,21 +85,19 @@ public class CheckerTestCase extends CodanTestCase {
loadcode(code); loadcode(code);
runCodan(); runCodan();
} }
public void loadCodeAndRunCpp(String code) { public void loadCodeAndRunCpp(String code) {
loadcode(code, true); loadcode(code, true);
runCodan(); runCodan();
} }
/** /**
* *
*/ */
protected void runCodan() { protected void runCodan() {
CodanRuntime.getInstance().getBuilder().processResource( CodanRuntime.getInstance().getBuilder().processResource(cproject.getProject(), NullPM);
cproject.getProject(), NPM);
try { try {
markers = cproject.getProject() markers = cproject.getProject().findMarkers(IProblemReporter.GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, 1);
.findMarkers(
IProblemReporter.GENERIC_CODE_ANALYSIS_MARKER_TYPE,
true, 1);
} catch (CoreException e) { } catch (CoreException e) {
fail(e.getMessage()); fail(e.getMessage());
} }