mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
Additional testcase for binding resolution.
This commit is contained in:
parent
94bee24a59
commit
6943fa5a50
2 changed files with 63 additions and 17 deletions
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
|
@ -348,4 +349,26 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
||||||
public void _testEnumeratorInStructScope() {fail("todo");}
|
public void _testEnumeratorInStructScope() {fail("todo");}
|
||||||
public void _testEnumeratorInUnionScope() {fail("todo");}
|
public void _testEnumeratorInUnionScope() {fail("todo");}
|
||||||
public void _testMemberAccess() {fail("todo");}
|
public void _testMemberAccess() {fail("todo");}
|
||||||
|
|
||||||
|
// // header file
|
||||||
|
// struct myStruct {
|
||||||
|
// int a;
|
||||||
|
// };
|
||||||
|
// union myUnion {
|
||||||
|
// int b;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// // referencing content
|
||||||
|
// struct myStruct;
|
||||||
|
// union myUnion;
|
||||||
|
// void test() {
|
||||||
|
// struct myStruct* u;
|
||||||
|
// union myUnion* v;
|
||||||
|
// u->a= 1; // since we include the definition, we may use the type.
|
||||||
|
// v->b= 1; // since we include the definition, we may use the type.
|
||||||
|
// }
|
||||||
|
public void testTypeDefinitionWithFwdDeclaration() {
|
||||||
|
getBindingFromASTName("a= 1", 1);
|
||||||
|
getBindingFromASTName("b= 1", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.index.tests;
|
package org.eclipse.cdt.internal.index.tests;
|
||||||
|
|
||||||
|
@ -1136,6 +1137,28 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
assertEquals(1, getIndex().findNames(binding2, IIndex.FIND_DEFINITIONS).length);
|
assertEquals(1, getIndex().findNames(binding2, IIndex.FIND_DEFINITIONS).length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// // header file
|
||||||
|
// struct myStruct {
|
||||||
|
// int a;
|
||||||
|
// };
|
||||||
|
// union myUnion {
|
||||||
|
// int b;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// // referencing content
|
||||||
|
// struct myStruct;
|
||||||
|
// union myUnion;
|
||||||
|
// void test() {
|
||||||
|
// struct myStruct* u;
|
||||||
|
// union myUnion* v;
|
||||||
|
// u->a= 1; // since we include the definition, we may use the type.
|
||||||
|
// v->b= 1; // since we include the definition, we may use the type.
|
||||||
|
// }
|
||||||
|
public void testTypeDefinitionWithFwdDeclaration() {
|
||||||
|
getBindingFromASTName("a= 1", 1);
|
||||||
|
getBindingFromASTName("b= 1", 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* CPP assertion helpers */
|
/* CPP assertion helpers */
|
||||||
/* ##################################################################### */
|
/* ##################################################################### */
|
||||||
|
|
||||||
|
@ -1227,19 +1250,19 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
||||||
* @param cqn
|
* @param cqn
|
||||||
* @param qn may be null
|
* @param qn may be null
|
||||||
*/
|
*/
|
||||||
static protected void assertPTM(IType type, String cqn, String qn) {
|
static protected void assertPTM(IType type, String cqn, String qn) {
|
||||||
try {
|
try {
|
||||||
assertTrue(type instanceof ICPPPointerToMemberType);
|
assertTrue(type instanceof ICPPPointerToMemberType);
|
||||||
ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type;
|
ICPPPointerToMemberType ptmt = (ICPPPointerToMemberType) type;
|
||||||
ICPPClassType classType = ptmt.getMemberOfClass();
|
ICPPClassType classType = ptmt.getMemberOfClass();
|
||||||
assertQNEquals(cqn, classType);
|
assertQNEquals(cqn, classType);
|
||||||
if(qn!=null) {
|
if(qn!=null) {
|
||||||
assert(ptmt.getType() instanceof ICPPBinding);
|
assert(ptmt.getType() instanceof ICPPBinding);
|
||||||
ICPPBinding tyBinding = (ICPPBinding) ptmt.getType();
|
ICPPBinding tyBinding = (ICPPBinding) ptmt.getType();
|
||||||
assertQNEquals(qn, tyBinding);
|
assertQNEquals(qn, tyBinding);
|
||||||
}
|
}
|
||||||
} catch(DOMException de) {
|
} catch(DOMException de) {
|
||||||
fail(de.getMessage());
|
fail(de.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue