From 9b75c68712682a335eb8158f7835cf9a85245766 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 17 Oct 2006 12:22:13 +0000 Subject: [PATCH] junit test for bug 161216, static functions/vars in PDOM --- .../indexer/tests/IndexSearchTest.java | 31 +++++++++++++++++++ .../indexTests/search/staticFunc1.cpp | 2 ++ .../indexTests/search/staticFunc2.cpp | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc1.cpp create mode 100644 core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc2.cpp diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/indexer/tests/IndexSearchTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/indexer/tests/IndexSearchTest.java index 007117c8654..ddea1bafb9b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/indexer/tests/IndexSearchTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/indexer/tests/IndexSearchTest.java @@ -22,7 +22,11 @@ import org.eclipse.cdt.core.dom.IPDOMNode; import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; +import org.eclipse.cdt.core.dom.ast.IFunction; +import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexBinding; @@ -112,6 +116,16 @@ public class IndexSearchTest extends BaseTestCase { assertTrue(binding instanceof IEnumeration); } + private void checkIsFunction(IIndexBinding binding) { + assertTrue(binding instanceof IFunction); + assertTrue(!(binding instanceof ICPPMethod)); + } + + private void checkIsVariable(IIndexBinding binding) { + assertTrue(binding instanceof IVariable); + assertTrue(!(binding instanceof ICPPField)); + } + public void testFindClassInNamespace() throws CoreException { Pattern pcl= Pattern.compile("C160913"); Pattern pns= Pattern.compile("ns160913"); @@ -220,6 +234,23 @@ public class IndexSearchTest extends BaseTestCase { checkIsEnumeration(bindings[0]); } + public void _testFindStatic_161216() throws CoreException { + Pattern pFunc= Pattern.compile("staticFunc20061017"); + Pattern pVar= Pattern.compile("staticVar20061017"); + + IIndexBinding[] bindings; + + bindings= fIndex.findBindings(pFunc, true, INDEX_FILTER, NPM); + assertEquals(2, bindings.length); + checkIsFunction(bindings[0]); + checkIsFunction(bindings[1]); + + bindings= fIndex.findBindings(pVar, true, INDEX_FILTER, NPM); + assertEquals(2, bindings.length); + checkIsVariable(bindings[0]); + checkIsVariable(bindings[1]); + } + public void testSanityOfMayHaveChildren() throws CoreException { PDOM pdom= (PDOM) ((CIndex) fIndex).getPrimaryFragments()[0]; pdom.accept(new IPDOMVisitor() { diff --git a/core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc1.cpp b/core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc1.cpp new file mode 100644 index 00000000000..0a9b76be9d8 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc1.cpp @@ -0,0 +1,2 @@ +static int staticFunc20061017(); +static int staticVar20061017; \ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc2.cpp b/core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc2.cpp new file mode 100644 index 00000000000..0a9b76be9d8 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/resources/indexTests/search/staticFunc2.cpp @@ -0,0 +1,2 @@ +static int staticFunc20061017(); +static int staticVar20061017; \ No newline at end of file