From e0256faf6bd9e29e79cc03ed53b3616eb64ea696 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 27 Jul 2007 10:13:37 +0000 Subject: [PATCH] Additional testcase for updating index. --- .../index/tests/IndexUpdateTests.java | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java index 0e74f5ea931..8d022449e05 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java @@ -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 { - fContents= getContentsForTest(totalFileVersions); + 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 {