1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Additional testcase for updating index.

This commit is contained in:
Markus Schorn 2007-07-27 10:13:37 +00:00
parent 6943fa5a50
commit e0256faf6b

View file

@ -70,6 +70,7 @@ public class IndexUpdateTests extends IndexTestBase {
private IIndex fIndex= null;
private StringBuffer[] fContents;
private IFile fFile;
private IFile fHeader;
private int fContentUsed;
public IndexUpdateTests(String name) {
@ -87,10 +88,23 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCppProject});
}
private void setupFile(int totalFileVersions, boolean cpp) throws Exception {
private void setupHeader(int totalFileVersions, boolean cpp) throws Exception {
if (fContents == null) {
fContents= getContentsForTest(totalFileVersions);
fContentUsed= -1;
}
IProject project= cpp ? fCppProject.getProject() : fCProject.getProject();
fFile= TestSourceReader.createFile(project, "file" + (cpp ? ".cpp" : ".c"), fContents[0].toString());
fFile= TestSourceReader.createFile(project, "header.h", fContents[++fContentUsed].toString());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM));
}
private void setupFile(int totalFileVersions, boolean cpp) throws Exception {
if (fContents == null) {
fContents= getContentsForTest(totalFileVersions);
fContentUsed= -1;
}
IProject project= cpp ? fCppProject.getProject() : fCProject.getProject();
fFile= TestSourceReader.createFile(project, "file" + (cpp ? ".cpp" : ".c"), fContents[++fContentUsed].toString());
fContentUsed= 0;
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM));
}
@ -104,8 +118,11 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex= null;
if (fFile != null) {
fFile.delete(true, NPM);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
}
if (fHeader != null) {
fHeader.delete(true, NPM);
}
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
super.tearDown();
}
@ -375,6 +392,23 @@ public class IndexUpdateTests extends IndexTestBase {
checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE, INLINE});
}
// class MyClass {protected: int method(int a, int b);};
// #include "header.h"
// int MyClass::method(int a, int b);
// #include "header.h"
// char MyClass::method(int a, int b);
public void testFixedCppMethod() throws Exception {
setupHeader(3, true);
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
setupFile(0, true);
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
updateFile();
checkCppMethod("MyClass::method", new String[] {INT, INT, INT}, new String[]{PROTECTED});
}
private void checkCppMethod(String name, String[] types, String[] modifiers) throws Exception {
fIndex.acquireReadLock();
try {