1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Testcase for 162758, by Andrew Ferguson.

This commit is contained in:
Markus Schorn 2006-10-30 16:38:09 +00:00
parent c8b7ec6935
commit 6b96ffedab
3 changed files with 77 additions and 1 deletions

View file

@ -0,0 +1,75 @@
/*******************************************************************************
* Copyright (c) 2006 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Symbian - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
import java.util.regex.Pattern;
import junit.framework.Test;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
/**
* See bugzilla
*/
public class FilesOnReindexTests extends PDOMTestBase {
protected ICProject project;
protected IIndex pdom;
public static Test suite() {
return suite(FilesOnReindexTests.class);
}
protected void setUp() throws Exception {
if (pdom == null) {
project = createProject("filesOnReindex");
pdom = CCorePlugin.getIndexManager().getIndex(project);
}
pdom.acquireReadLock();
}
protected void tearDown() throws Exception {
pdom.releaseReadLock();
}
public void testFilesOnReindex() throws CoreException, InterruptedException {
IFile file = project.getProject().getFile("simple.cpp");
performAssertions(file);
pdom.releaseReadLock();
CCorePlugin.getPDOMManager().getIndexer(project).reindex();
// wait until the indexer is done
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
pdom.acquireReadLock();
performAssertions(file);
}
void performAssertions(IFile file) throws CoreException {
IIndex index = CCorePlugin.getIndexManager().getIndex(project);
assertNotNull(index.getFile(file.getLocation()));
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, new IndexFilter(), new NullProgressMonitor());
assertEquals(1, bs.length);
PDOMBinding binding = (PDOMBinding) bs[0];
IIndexFile file2 = binding.getFirstDefinition().getFile();
assertEquals(file.getLocation().toOSString(), file2.getLocation());
}
}

View file

@ -29,7 +29,7 @@ public class PDOMTests extends TestSuite {
suite.addTestSuite(OverloadsWithinSingleTUTests.class);
suite.addTest(OverloadsWithinCommonHeaderTests.suite());
suite.addTestSuite(BTreeTests.class);
suite.addTest(FilesOnReindexTests.suite());
suite.addTest(CPPFieldTests.suite());
suite.addTest(CPPFunctionTests.suite());

View file

@ -0,0 +1 @@
class C {};