mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Brent Nicolle
Added Interface tests for IStructure.
This commit is contained in:
parent
d45de32ff5
commit
b1c1e00a78
5 changed files with 543 additions and 44 deletions
|
@ -1,7 +1,5 @@
|
|||
2003-06-14 Victor Mozgin
|
||||
Moved testBugSingleton192() from LokiFailures to DOMTests.
|
||||
Added testPointersToMembers() and testPointersToMemberFunctions() to DOMTests.
|
||||
Added testBug36290() and testBug36931() to DOMTests.
|
||||
2003-06-17 Brent Nicolle
|
||||
Added Interface tests of IStructure.java.
|
||||
|
||||
2003-06-16 Vladimir Hirsl
|
||||
Added /build, /parser, /failures and /suite directories to the library.
|
||||
|
@ -10,6 +8,11 @@
|
|||
Added class AISResultPrinter to format test results.
|
||||
Class AutomatedIntegrationSuite now implements IPlatformRunnable.
|
||||
|
||||
2003-06-14 Victor Mozgin
|
||||
Moved testBugSingleton192() from LokiFailures to DOMTests.
|
||||
Added testPointersToMembers() and testPointersToMemberFunctions() to DOMTests.
|
||||
Added testBug36290() and testBug36931() to DOMTests.
|
||||
|
||||
2003-06-13 John Camelon
|
||||
Added Class/Base infrastructure to public interfaces & requestor callback.
|
||||
Moved many internal interfaces to external packages.
|
||||
|
|
|
@ -1,4 +1,88 @@
|
|||
// IStructure
|
||||
struct foo {
|
||||
int bar;
|
||||
struct testStruct1 {
|
||||
char m_field1;
|
||||
char* m_field2;
|
||||
unsigned char m_field3;
|
||||
int m_field4;
|
||||
unsigned m_field5;
|
||||
void* m_field6;
|
||||
|
||||
void method1();
|
||||
struct testStruct1 method2( char* in_field2, int in_field4 ) {}
|
||||
// this is very C++:
|
||||
testStruct1( char* in_field2, int in_field4 ) {}
|
||||
~testStruct1() {}
|
||||
};
|
||||
|
||||
struct testStruct2 {
|
||||
};
|
||||
|
||||
struct testStruct3 {
|
||||
} aTestStruct3;
|
||||
|
||||
// no semicolon, parser should recover
|
||||
struct testStruct4NoSemicolon {
|
||||
}
|
||||
|
||||
// forward declaration
|
||||
struct testStruct5;
|
||||
|
||||
// variable declaration using predefined struct.
|
||||
struct testStruct6 aTestStruct6;
|
||||
|
||||
struct {
|
||||
int x;
|
||||
} testAnonymousStructObject1;
|
||||
|
||||
struct {
|
||||
int x;
|
||||
} testAnonymousStructObject2= {1};
|
||||
|
||||
// to resync the parser if necessary
|
||||
struct testStruct7 {
|
||||
};
|
||||
|
||||
// an inner struct
|
||||
struct testStruct8 {
|
||||
struct testStruct9Inner {
|
||||
int x;
|
||||
};
|
||||
struct testStruct10Inner {
|
||||
int y;
|
||||
struct testStruct11Inner {
|
||||
int z;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
union testUnion1 {
|
||||
char m_field1;
|
||||
char* m_field2;
|
||||
unsigned char m_field3;
|
||||
int m_field4;
|
||||
unsigned m_field5;
|
||||
void* m_field6;
|
||||
};
|
||||
|
||||
class testClass1 {
|
||||
};
|
||||
|
||||
class testClass2NoSemicolon {
|
||||
}
|
||||
|
||||
class testClass3 {
|
||||
};
|
||||
|
||||
class testClass4Abstract {
|
||||
void aNonVirtual();
|
||||
virtual void aVirtual();
|
||||
virtual void aPureVirtual()=0;
|
||||
};
|
||||
|
||||
class testClass5
|
||||
: public testClass1, protected testClass3, private testClass4Abstract {
|
||||
};
|
||||
|
||||
// to resync the parser if necessary
|
||||
class testClass6 {
|
||||
};
|
||||
|
|
|
@ -27,8 +27,8 @@ public class IMacroTests extends IntegratedCModelTest {
|
|||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite( IMacroTests.class.getName() );
|
||||
suite.addTest( new IMacroTests("testGetElementName"));
|
||||
// TODO: suite.addTest( new IMacroTest("testGetIdentifierList"));
|
||||
// TODO: suite.addTest( new IMacroTest("testGetTokenSequence"));
|
||||
// TODO Bug# 38740: suite.addTest( new IMacroTest("testGetIdentifierList"));
|
||||
// TODO Bug# 38740: suite.addTest( new IMacroTest("testGetTokenSequence"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.model.tests;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IStructure;
|
||||
import org.eclipse.cdt.core.model.IField;
|
||||
import org.eclipse.cdt.core.model.*;
|
||||
|
||||
import junit.framework.*;
|
||||
|
||||
|
@ -44,52 +42,381 @@ public class IStructureTests extends IntegratedCModelTest {
|
|||
*/
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite( IStructureTests.class.getName() );
|
||||
// TODO: suite.addTest( new IStructureTests("testGetField"));
|
||||
|
||||
// TODO: implement the other tests here once IStructure is properly implemented!
|
||||
// TODO check C-only behaviour using C_NATURE vs CC_NATURE
|
||||
|
||||
// Interface tests:
|
||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeStruct"));
|
||||
suite.addTest( new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
|
||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetFields"));
|
||||
suite.addTest( new IStructureTests("testGetFieldsHack"));
|
||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetField"));
|
||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetMethods")); // C++ only
|
||||
suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only
|
||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetMethod")); // C++ only
|
||||
suite.addTest( new IStructureTests("testIsStruct"));
|
||||
suite.addTest( new IStructureTests("testIsClass")); // C++ only
|
||||
suite.addTest( new IStructureTests("testIsUnion"));
|
||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testIsAbstract")); // C++ only
|
||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only
|
||||
// TODO Bug# 38985: suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only
|
||||
|
||||
// Language Specification tests:
|
||||
suite.addTest( new IStructureTests("testAnonymousStructObject"));
|
||||
suite.addTest( new IStructureTests("testInnerStruct"));
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
||||
public void testGetAccessControl() {
|
||||
// test getAccessControl()
|
||||
// test getAccessControl(int)
|
||||
public void testGetChildrenOfTypeStruct() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList arrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
String[] myExpectedStructs = {
|
||||
"testStruct1", "testStruct2", "testStruct3",
|
||||
/* 2 anonymous structs */ "", "", "testStruct7",
|
||||
"testStruct8"
|
||||
};
|
||||
assertEquals(myExpectedStructs.length,arrayStructs.size());
|
||||
for(int i=0; i<myExpectedStructs.length; i++) {
|
||||
IStructure myIStruct = (IStructure) arrayStructs.get(i);
|
||||
assertNotNull( "Failed on "+i, myIStruct);
|
||||
assertEquals(myExpectedStructs[i], myIStruct.getElementName());
|
||||
}
|
||||
}
|
||||
public void testGetBaseTypes() {
|
||||
public void testGetChildrenOfTypeClass() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
|
||||
String[] myExpectedClasses = {
|
||||
"testClass1", "testClass3", "testClass4Abstract",
|
||||
"testClass5", "testClass6" };
|
||||
assertEquals(myExpectedClasses.length,arrayClasses.size());
|
||||
for(int i=0; i<myExpectedClasses.length; i++) {
|
||||
IStructure myIStruct = (IStructure) arrayClasses.get(i);
|
||||
assertNotNull( "Failed on "+i, myIStruct);
|
||||
assertEquals(myExpectedClasses[i], myIStruct.getElementName());
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetFields() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
IField[] myArrayIField = myIStruct.getFields();
|
||||
String[] myExpectedFields = {
|
||||
"m_field1","m_field2","m_field3",
|
||||
"m_field4","m_field5","m_field6",
|
||||
};
|
||||
assertEquals(myExpectedFields.length, myArrayIField.length);
|
||||
for(int i=0; i<myArrayIField.length; i++) {
|
||||
assertNotNull( "Failed on "+i, myArrayIField[i]);
|
||||
assertEquals("Failed on "+i,
|
||||
myExpectedFields[i], myArrayIField[i].getElementName());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Bug# 38985: remove testGetFieldsHack()
|
||||
public void testGetFieldsHack() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
String[] myExpectedFields = {
|
||||
"m_field1","m_field2","m_field3",
|
||||
"m_field4","m_field5","m_field6",
|
||||
};
|
||||
ArrayList myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
|
||||
assertEquals(myExpectedFields.length, myArrayIField.size());
|
||||
for(int i=0; i<myArrayIField.size(); i++) {
|
||||
IField myIField = (IField) myArrayIField.get(i);
|
||||
assertNotNull( "Failed on "+i, myIField );
|
||||
assertEquals("Failed on "+i,
|
||||
myExpectedFields[i], myIField.getElementName());
|
||||
}
|
||||
}
|
||||
public void testGetField() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList arrayStructs = tu.getChildrenOfType(ITranslationUnit.C_STRUCT);
|
||||
ArrayList arrayClasses = tu.getChildrenOfType(ITranslationUnit.C_CLASS);
|
||||
IStructure myIStruct = (IStructure) arrayStructs.get(0);
|
||||
assertNotNull(myIStruct);
|
||||
IField myIField = myIStruct.getField("bar");
|
||||
assertNotNull(myIField);
|
||||
}
|
||||
public void testGetFields() {
|
||||
}
|
||||
public void testGetInitializer() {
|
||||
}
|
||||
public void testGetMethod() {
|
||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
String[] myExpectedFields = {
|
||||
"m_field1","m_field2","m_field3",
|
||||
"m_field4","m_field5","m_field6",
|
||||
};
|
||||
for(int i=0; i<myExpectedFields.length; i++) {
|
||||
IField myIField = myIStruct.getField( myExpectedFields[i] );
|
||||
assertNotNull( "Failed on "+i, myIField);
|
||||
}
|
||||
|
||||
String[] myUnexpectedFields = {
|
||||
"m_field7","m_field8","m_field9",
|
||||
};
|
||||
for(int i=0; i<myUnexpectedFields.length; i++) {
|
||||
IField myIField = myIStruct.getField( myUnexpectedFields[i] );
|
||||
assertNull( "Failed on "+i, myIField);
|
||||
}
|
||||
}
|
||||
public void testGetMethods() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
IMethod[] myArrayIMethod = myIStruct.getMethods();
|
||||
String[] myExpectedMethods = {
|
||||
"method1","method2","testStruct1","~testStruct1"
|
||||
};
|
||||
assertEquals(myExpectedMethods.length, myArrayIMethod.length);
|
||||
for(int i=0; i<myArrayIMethod.length; i++) {
|
||||
assertNotNull( "Failed on "+i, myArrayIMethod[i]);
|
||||
assertEquals("Failed on "+i,
|
||||
myExpectedMethods[i], myArrayIMethod[i].getElementName());
|
||||
}
|
||||
}
|
||||
public void testGetStructureInfo() {
|
||||
// TODO Bug# 38985: remove testGetMethodsHack()
|
||||
public void testGetMethodsHack() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
ArrayList myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
|
||||
myArrayIMethod.addAll( myIStruct.getChildrenOfType(ICElement.C_METHOD) );
|
||||
String[] myExpectedMethods = {
|
||||
"method1","method2","testStruct1","~testStruct1"
|
||||
};
|
||||
assertEquals(myExpectedMethods.length, myArrayIMethod.size());
|
||||
for(int i=0; i<myArrayIMethod.size(); i++) {
|
||||
IMethodDeclaration myIMethod = (IMethodDeclaration) myArrayIMethod.get(i);
|
||||
assertNotNull( "Failed on "+i, myIMethod);
|
||||
assertEquals("Failed on "+i,
|
||||
myExpectedMethods[i], myIMethod.getElementName());
|
||||
}
|
||||
}
|
||||
public void testGetTypeName() {
|
||||
public void testGetMethod() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ArrayList myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
|
||||
IStructure myIStruct = (IStructure) myArrayStructs.get(0);
|
||||
String[] myExpectedMethods = {
|
||||
"method1","method2","testStruct1","~testStruct1"
|
||||
};
|
||||
for(int i=0; i<myExpectedMethods.length; i++) {
|
||||
IMethod myIMethod = myIStruct.getMethod( myExpectedMethods[i] );
|
||||
assertNotNull( "Failed on "+i, myIMethod);
|
||||
}
|
||||
|
||||
String[] myUnexpectedMethods = {
|
||||
"method7","method8","method9",
|
||||
};
|
||||
for(int i=0; i<myUnexpectedMethods.length; i++) {
|
||||
IMethod myIMethod = myIStruct.getMethod( myUnexpectedMethods[i] );
|
||||
assertNull( "Failed on "+i, myIMethod);
|
||||
}
|
||||
}
|
||||
public void testIsAbstract() {
|
||||
}
|
||||
public void testIsClass() {
|
||||
}
|
||||
public void testIsConst() {
|
||||
}
|
||||
public void testIsStatic() {
|
||||
|
||||
public void testIsUnion() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementUnion = null;
|
||||
ICElement myElementNonUnion = null;
|
||||
try {
|
||||
myElementUnion = tu.getElement("testUnion1");
|
||||
myElementNonUnion = tu.getElement("testStruct1");
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementUnion );
|
||||
assertTrue( myElementUnion.getElementType()==ICElement.C_UNION );
|
||||
IStructure myStructUnion = (IStructure) myElementUnion;
|
||||
assertNotNull( myStructUnion );
|
||||
assertTrue( myStructUnion.isUnion() );
|
||||
|
||||
assertNotNull( myElementNonUnion );
|
||||
assertTrue( myElementNonUnion.getElementType()!=ICElement.C_UNION );
|
||||
IStructure myStructNonUnion = (IStructure) myElementNonUnion;
|
||||
assertNotNull( myStructNonUnion );
|
||||
assertFalse( myStructNonUnion.isUnion() );
|
||||
}
|
||||
public void testIsStruct() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementStruct = null;
|
||||
ICElement myElementNonStruct = null;
|
||||
try {
|
||||
myElementStruct = tu.getElement("testStruct1");
|
||||
myElementNonStruct = tu.getElement("testClass1");
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementStruct );
|
||||
assertTrue( myElementStruct.getElementType()==ICElement.C_STRUCT );
|
||||
IStructure myStructStruct = (IStructure) myElementStruct;
|
||||
assertNotNull( myStructStruct );
|
||||
assertTrue( myStructStruct.isStruct() );
|
||||
|
||||
assertNotNull( myElementNonStruct );
|
||||
assertTrue( myElementNonStruct.getElementType()!=ICElement.C_STRUCT );
|
||||
IStructure myStructNonStruct = (IStructure) myElementNonStruct;
|
||||
assertNotNull( myStructNonStruct );
|
||||
assertFalse( myStructNonStruct.isStruct() );
|
||||
}
|
||||
public void testIsUnion() {
|
||||
|
||||
public void testIsClass() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementClass = null;
|
||||
ICElement myElementNonClass = null;
|
||||
try {
|
||||
myElementClass = tu.getElement("testClass1");
|
||||
myElementNonClass = tu.getElement("testStruct1");
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementClass );
|
||||
assertTrue( myElementClass.getElementType()==ICElement.C_CLASS );
|
||||
IStructure myStructClass = (IStructure) myElementClass;
|
||||
assertNotNull( myStructClass );
|
||||
assertTrue( myStructClass.isClass() );
|
||||
|
||||
assertNotNull( myElementNonClass );
|
||||
assertTrue( myElementNonClass.getElementType()!=ICElement.C_CLASS );
|
||||
IStructure myStructNonClass = (IStructure) myElementNonClass;
|
||||
assertNotNull( myStructNonClass );
|
||||
assertFalse( myStructNonClass.isClass() );
|
||||
}
|
||||
public void testIsVolatile() {
|
||||
|
||||
public void testIsAbstract() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementAbstract = null;
|
||||
ICElement myElementNonAbstract = null;
|
||||
try {
|
||||
myElementAbstract = tu.getElement("testClass4Abstract");
|
||||
myElementNonAbstract = tu.getElement("testClass1");
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElementAbstract );
|
||||
assertTrue( myElementAbstract.getElementType()==ICElement.C_CLASS );
|
||||
IStructure myStructAbstract = (IStructure) myElementAbstract;
|
||||
assertNotNull( myStructAbstract );
|
||||
assertTrue( myStructAbstract.isAbstract() );
|
||||
|
||||
assertNotNull( myElementNonAbstract );
|
||||
assertTrue( myElementNonAbstract.getElementType()!=ICElement.C_CLASS );
|
||||
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
|
||||
assertNotNull( myStructNonAbstract );
|
||||
assertFalse( myStructNonAbstract.isAbstract() );
|
||||
}
|
||||
|
||||
// IInheritance
|
||||
public void testGetBaseTypes() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementDerived = null;
|
||||
IStructure[] myBaseTypes = null;
|
||||
try {
|
||||
myElementDerived = tu.getElement("testClass5"); // throws
|
||||
assertNotNull( myElementDerived );
|
||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||
assertNotNull( myStructDerived );
|
||||
myBaseTypes = myStructDerived.getBaseTypes(); // throws
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
|
||||
String[] myExpectedBaseTypes = {
|
||||
"testClass1","testClass3","testClass4"
|
||||
};
|
||||
assertEquals( myExpectedBaseTypes.length, myBaseTypes.length );
|
||||
for(int i=0; i<myBaseTypes.length; i++) {
|
||||
assertEquals( "Failed on "+i, myExpectedBaseTypes[i], myBaseTypes[i].getElementName() );
|
||||
}
|
||||
}
|
||||
|
||||
// tests IInheritance.getAccessControl(int),
|
||||
// not IDeclaration.getAccessControl()
|
||||
public void testGetAccessControl() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElementDerived = null;
|
||||
IStructure[] myBaseTypes = null;
|
||||
try {
|
||||
myElementDerived = tu.getElement("testClass5"); // throws
|
||||
assertNotNull( myElementDerived );
|
||||
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS );
|
||||
IStructure myStructDerived = (IStructure) myElementDerived;
|
||||
assertNotNull( myStructDerived );
|
||||
myBaseTypes = myStructDerived.getBaseTypes(); // throws
|
||||
|
||||
int[] myExpectedAccessControl = {
|
||||
// TODO #38986: expect appropriate access control tags
|
||||
ICElement.CPP_PUBLIC,
|
||||
org.eclipse.cdt.core.index.TagFlags.T_PROTECTED,
|
||||
ICElement.CPP_PRIVATE
|
||||
};
|
||||
assertEquals( myExpectedAccessControl.length, myBaseTypes.length );
|
||||
for(int i=0; i<myBaseTypes.length; i++) {
|
||||
int myAccessControl = myStructDerived.getAccessControl(i); // throws
|
||||
assertEquals( "Failed on "+i, myExpectedAccessControl[i], myAccessControl );
|
||||
}
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
}
|
||||
|
||||
// getStructureInfo
|
||||
public void testGetStructureInfo() {
|
||||
}
|
||||
|
||||
// TODO: Not tested; Bug# 38958. public void testGetInitializer()
|
||||
// TODO: Not tested; Bug# 38958. public void testGetTypeName()
|
||||
// TODO: Not tested; Bug# 38958. public void testIsConst()
|
||||
// TODO: Not tested; Bug# 38958. public void testIsStatic()
|
||||
// TODO: Not tested; Bug# 38958. public void testIsVolatile()
|
||||
// TODO: Not tested; Bug# 38958. public void testGetAccessControl_Void()
|
||||
|
||||
//
|
||||
// Language Specification Tests
|
||||
//
|
||||
|
||||
public void testAnonymousStructObject() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElement = null;
|
||||
try {
|
||||
myElement = tu.getElement("testAnonymousStructObject1");
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElement );
|
||||
assertEquals( ICElement.C_VARIABLE, myElement.getElementType() );
|
||||
}
|
||||
|
||||
public void testInnerStruct() {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement myElement = null;
|
||||
try {
|
||||
myElement = tu.getElement("testStruct8");
|
||||
}
|
||||
catch( CModelException c )
|
||||
{
|
||||
assertNotNull("CModelException thrown",c);
|
||||
}
|
||||
assertNotNull( myElement );
|
||||
IStructure myIStruct = (IStructure) myElement;
|
||||
assertNotNull( myIStruct );
|
||||
|
||||
String[] myExpectedInnerStructs = {
|
||||
"testStruct9Inner", "testStruct10Inner"
|
||||
};
|
||||
ArrayList myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
|
||||
assertEquals( myExpectedInnerStructs.length, myInnerStructs.size() );
|
||||
for(int i=0; i<myExpectedInnerStructs.length; i++) {
|
||||
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
|
||||
assertNotNull( "Failed on "+i, myInnerStruct );
|
||||
assertEquals( "Failed on "+i, myExpectedInnerStructs[i], myInnerStruct.getElementName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,89 @@
|
|||
// IStructure
|
||||
struct foo {
|
||||
int bar;
|
||||
struct testStruct1 {
|
||||
char m_field1;
|
||||
char* m_field2;
|
||||
unsigned char m_field3;
|
||||
int m_field4;
|
||||
unsigned m_field5;
|
||||
void* m_field6;
|
||||
|
||||
void method1();
|
||||
struct testStruct1 method2( char* in_field2, int in_field4 ) {}
|
||||
// this is very C++:
|
||||
testStruct1( char* in_field2, int in_field4 ) {}
|
||||
~testStruct1() {}
|
||||
};
|
||||
|
||||
struct testStruct2 {
|
||||
};
|
||||
|
||||
struct testStruct3 {
|
||||
} aTestStruct3;
|
||||
|
||||
// no semicolon, parser should recover
|
||||
struct testStruct4NoSemicolon {
|
||||
}
|
||||
|
||||
// forward declaration
|
||||
struct testStruct5;
|
||||
|
||||
// variable declaration using predefined struct.
|
||||
struct testStruct6 aTestStruct6;
|
||||
|
||||
struct {
|
||||
int x;
|
||||
} testAnonymousStructObject1;
|
||||
|
||||
struct {
|
||||
int x;
|
||||
} testAnonymousStructObject2= {1};
|
||||
|
||||
// to resync the parser if necessary
|
||||
struct testStruct7 {
|
||||
};
|
||||
|
||||
// an inner struct
|
||||
struct testStruct8 {
|
||||
struct testStruct9Inner {
|
||||
int x;
|
||||
};
|
||||
struct testStruct10Inner {
|
||||
int y;
|
||||
struct testStruct11Inner {
|
||||
int z;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
union testUnion1 {
|
||||
char m_field1;
|
||||
char* m_field2;
|
||||
unsigned char m_field3;
|
||||
int m_field4;
|
||||
unsigned m_field5;
|
||||
void* m_field6;
|
||||
};
|
||||
|
||||
class testClass1 {
|
||||
};
|
||||
|
||||
class testClass2NoSemicolon {
|
||||
}
|
||||
|
||||
class testClass3 {
|
||||
};
|
||||
|
||||
class testClass4Abstract {
|
||||
void aNonVirtual();
|
||||
virtual void aVirtual();
|
||||
virtual void aPureVirtual()=0;
|
||||
};
|
||||
|
||||
class testClass5
|
||||
: public testClass1, protected testClass3, private testClass4Abstract {
|
||||
};
|
||||
|
||||
// to resync the parser if necessary
|
||||
class testClass6 {
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue