mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Move assertInstance() up from AST2TestBase to BaseTestCase
Change-Id: Ibe45d247f6f027691625a04fcc8971f84e2764a7 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
102c7b58cf
commit
2cc3e248b4
2 changed files with 12 additions and 10 deletions
|
@ -505,16 +505,6 @@ public class AST2TestBase extends BaseTestCase {
|
||||||
return TestSourceReader.getContentsForTest(plugin.getBundle(), "parser", getClass(), getName(), sections);
|
return TestSourceReader.getContentsForTest(plugin.getBundle(), "parser", getClass(), getName(), sections);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
|
|
||||||
assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o);
|
|
||||||
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
|
|
||||||
for (Class c : cs) {
|
|
||||||
assertNotNull("Expected object of " + c.getName() + " but got a null value", o);
|
|
||||||
assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
|
|
||||||
}
|
|
||||||
return clazz.cast(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
|
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
|
||||||
assertInstance(binding, IField.class);
|
assertInstance(binding, IField.class);
|
||||||
assertEquals(fieldName, binding.getName());
|
assertEquals(fieldName, binding.getName());
|
||||||
|
|
|
@ -337,4 +337,16 @@ public class BaseTestCase extends TestCase {
|
||||||
public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception {
|
public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception {
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000);
|
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assertion helpers
|
||||||
|
|
||||||
|
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
|
||||||
|
assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o);
|
||||||
|
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
|
||||||
|
for (Class c : cs) {
|
||||||
|
assertNotNull("Expected object of " + c.getName() + " but got a null value", o);
|
||||||
|
assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
|
||||||
|
}
|
||||||
|
return clazz.cast(o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue