mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
added convinience method to use outside of the package
This commit is contained in:
parent
4975d5a2c7
commit
899b6159ac
2 changed files with 17 additions and 3 deletions
|
@ -28,7 +28,12 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
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")
|
@SuppressWarnings("nls")
|
||||||
public class CheckerTestCase extends CodanTestCase {
|
public class CheckerTestCase extends CodanTestCase {
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: add description
|
* TODO: add description
|
||||||
|
@ -171,14 +172,22 @@ public class CodanTestCase extends BaseTestCase {
|
||||||
|
|
||||||
protected StringBuffer[] getContents(int sections) {
|
protected StringBuffer[] getContents(int sections) {
|
||||||
try {
|
try {
|
||||||
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
|
return TestSourceReader.getContentsForTest(getPlugin().getBundle(), getSourcePrefix(), getClass(), getName(), sections);
|
||||||
return TestSourceReader.getContentsForTest(plugin.getBundle(), "src", getClass(), getName(), sections);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getSourcePrefix() {
|
||||||
|
return "src";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Plugin getPlugin() {
|
||||||
|
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
public File loadcode(String code, boolean cpp) {
|
public File loadcode(String code, boolean cpp) {
|
||||||
String fileKey = "@file:";
|
String fileKey = "@file:";
|
||||||
int indf = code.indexOf(fileKey);
|
int indf = code.indexOf(fileKey);
|
||||||
|
|
Loading…
Add table
Reference in a new issue