1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 17:25:38 +02:00

173997: add a related test case

This commit is contained in:
Andrew Ferguson 2007-05-09 11:54:51 +00:00
parent d5aad42f70
commit 6c161d4b54

View file

@ -117,6 +117,47 @@ public class IndexBugsTests extends BaseTestCase {
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, time);
}
// class A {};
// class B {};
// A var;
// class A {};
// class B {};
// B var;
public void _test173997_2() throws Exception {
StringBuffer[] content= getContentsForTest(3);
IFile file= createFile(getProject(), "header.h", content[0].toString());
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, NPM);
assertEquals(1, bs.length);
assertTrue(bs[0] instanceof ICPPVariable);
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
assertEquals("A", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
} finally {
index.releaseReadLock();
}
file.setContents(new ByteArrayInputStream(content[1].toString().getBytes()), true, false, NPM);
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
index= CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
try {
IBinding[] bs= index.findBindings("var".toCharArray(), IndexFilter.ALL, NPM);
assertEquals(1, bs.length);
assertTrue(bs[0] instanceof ICPPVariable);
assertTrue(((ICPPVariable)bs[0]).getType() instanceof ICPPClassType);
assertEquals("B", ((ICPPClassType)(((ICPPVariable)bs[0]).getType())).getName());
} finally {
index.releaseReadLock();
}
}
// namespace ns162011 {
// class Class162011 {
// friend void function162011(Class162011);