mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Adds testcase for bug 173997, typedef definitions in index.
This commit is contained in:
parent
88faee0afe
commit
4386f43881
2 changed files with 55 additions and 1 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.IName;
|
|||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
|
@ -488,4 +489,53 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
// typedef int T20070213;
|
||||
public void _test173997() throws Exception {
|
||||
waitForIndexer();
|
||||
String content= getContentsForTest(1)[0].toString();
|
||||
|
||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
IBinding[] bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), NPM);
|
||||
assertEquals(1, bindings.length);
|
||||
assertTrue(bindings[0] instanceof ITypedef);
|
||||
ITypedef td= (ITypedef) bindings[0];
|
||||
IType type= td.getType();
|
||||
assertTrue(type instanceof IBasicType);
|
||||
IBasicType btype= (IBasicType) type;
|
||||
assertEquals(IBasicType.t_int, btype.getType());
|
||||
}
|
||||
finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
||||
long timestamp= file.getLocalTimeStamp();
|
||||
content= "int UPDATED20070213;\n" + content.replaceFirst("int", "float");
|
||||
file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
// double check if file was indexed
|
||||
IBinding[] bindings= fIndex.findBindings("UPDATED20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), NPM);
|
||||
assertEquals(1, bindings.length);
|
||||
|
||||
bindings= fIndex.findBindings("T20070213".toCharArray(), IndexFilter.getFilter(ILinkage.CPP_LINKAGE_ID), NPM);
|
||||
assertEquals(1, bindings.length);
|
||||
assertTrue(bindings[0] instanceof ITypedef);
|
||||
ITypedef td= (ITypedef) bindings[0];
|
||||
IType type= td.getType();
|
||||
assertTrue(type instanceof IBasicType);
|
||||
IBasicType btype= (IBasicType) type;
|
||||
assertTrue(IBasicType.t_int != btype.getType());
|
||||
assertEquals(IBasicType.t_float, btype.getType());
|
||||
}
|
||||
finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,11 @@ public class TestSourceReader {
|
|||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||
//Create file input stream
|
||||
if (file.exists()) {
|
||||
long timestamp= file.getLocalTimeStamp();
|
||||
file.setContents(stream, false, false, new NullProgressMonitor());
|
||||
if (file.getLocalTimeStamp() == timestamp) {
|
||||
file.setLocalTimeStamp(timestamp+1000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
file.create(stream, false, new NullProgressMonitor());
|
||||
|
|
Loading…
Add table
Reference in a new issue