1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

added convinience method to use outside of the package

This commit is contained in:
Alena Laskavaia 2011-03-19 17:20:56 +00:00
parent 4975d5a2c7
commit 899b6159ac
2 changed files with 17 additions and 3 deletions

View file

@ -28,7 +28,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
/**
* @author Alena Laskavaia
* Base class for tests. If you want to use outside of this plugin, you need
* to override {@link #getPlugin()} method and maybe {@link #getSourcePrefix()}
* method to get source directory for the tests,
* default is "src". To make it read comment from java class, you need to
* include this source directory (with test java files) into the build bundle.
*
*/
@SuppressWarnings("nls")
public class CheckerTestCase extends CodanTestCase {

View file

@ -34,6 +34,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
/**
* TODO: add description
@ -171,14 +172,22 @@ public class CodanTestCase extends BaseTestCase {
protected StringBuffer[] getContents(int sections) {
try {
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
return TestSourceReader.getContentsForTest(plugin.getBundle(), "src", getClass(), getName(), sections);
return TestSourceReader.getContentsForTest(getPlugin().getBundle(), getSourcePrefix(), getClass(), getName(), sections);
} catch (IOException e) {
fail(e.getMessage());
return null;
}
}
protected String getSourcePrefix() {
return "src";
}
protected Plugin getPlugin() {
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
return plugin;
}
public File loadcode(String code, boolean cpp) {
String fileKey = "@file:";
int indf = code.indexOf(fileKey);