mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Additional testcase for updating index.
This commit is contained in:
parent
6943fa5a50
commit
e0256faf6b
1 changed files with 38 additions and 4 deletions
|
@ -70,6 +70,7 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
private IIndex fIndex= null;
|
private IIndex fIndex= null;
|
||||||
private StringBuffer[] fContents;
|
private StringBuffer[] fContents;
|
||||||
private IFile fFile;
|
private IFile fFile;
|
||||||
|
private IFile fHeader;
|
||||||
private int fContentUsed;
|
private int fContentUsed;
|
||||||
|
|
||||||
public IndexUpdateTests(String name) {
|
public IndexUpdateTests(String name) {
|
||||||
|
@ -87,10 +88,23 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCppProject});
|
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);
|
fContents= getContentsForTest(totalFileVersions);
|
||||||
|
fContentUsed= -1;
|
||||||
|
}
|
||||||
IProject project= cpp ? fCppProject.getProject() : fCProject.getProject();
|
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;
|
fContentUsed= 0;
|
||||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM));
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM));
|
||||||
}
|
}
|
||||||
|
@ -104,8 +118,11 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
fIndex= null;
|
fIndex= null;
|
||||||
if (fFile != null) {
|
if (fFile != null) {
|
||||||
fFile.delete(true, NPM);
|
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();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,6 +392,23 @@ public class IndexUpdateTests extends IndexTestBase {
|
||||||
checkCppMethod("MyClass::method", new String[] {INT, CHAR}, new String[]{PRIVATE, INLINE});
|
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 {
|
private void checkCppMethod(String name, String[] types, String[] modifiers) throws Exception {
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue