1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Run testStringConcatenationWithMacro test for both, C and C++.

This commit is contained in:
Sergey Prigogin 2015-06-25 16:30:04 -07:00
parent 6ab4145c56
commit 814ee56c8a
3 changed files with 25 additions and 11 deletions

View file

@ -176,8 +176,7 @@ public class AST2CPPTests extends AST2TestBase {
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
String code= getAboveComment();
return new BindingAssertionHelper(code, true);
return getAssertionHelper(CPP);
}
private void assertProblemBinding(int id, IBinding b) {
@ -7843,15 +7842,6 @@ public class AST2CPPTests extends AST2TestBase {
checkDeclDef(declNames, defNames, cls.getMembers());
}
// #define MACRO "macro"
// void f(const char* s);
// void test() {
// f("aaa"MACRO);
// }
public void testStringConcatenationWithMacro() throws Exception {
parseAndCheckBindings();
}
// class X {
// struct S* m1;
// struct T;

View file

@ -15,6 +15,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import static org.eclipse.cdt.core.parser.ParserLanguage.C;
import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
import java.io.IOException;
@ -110,6 +111,7 @@ import junit.framework.AssertionFailedError;
*/
public class AST2TestBase extends BaseTestCase {
public final static String TEST_CODE = "<testcode>";
protected static final ParserLanguage[] C_AND_CPP = new ParserLanguage[] { C, CPP };
protected static final IParserLogService NULL_LOG = new NullLogService();
protected static boolean sValidateCopy;
@ -838,6 +840,11 @@ public class AST2TestBase extends BaseTestCase {
return tu;
}
protected BindingAssertionHelper getAssertionHelper(ParserLanguage lang) throws ParserException, IOException {
String code= getAboveComment();
return new BindingAssertionHelper(code, lang);
}
final protected void assertNoProblemBindings(NameCollector col) {
for (IASTName n : col.nameList) {
assertFalse("ProblemBinding for " + n.getRawSignature(), n.resolveBinding() instanceof IProblemBinding);

View file

@ -715,6 +715,23 @@ public class AST2Tests extends AST2TestBase {
}
}
// #define _MACRO "macro"
// #define MACRO _MACRO
// void f(const char* s);
// void test() {
// f("aaa"MACRO);
// }
public void testStringConcatenationWithMacro() throws Exception {
for (ParserLanguage lang : C_AND_CPP) {
BindingAssertionHelper bh = getAssertionHelper(lang);
IASTName name = bh.findName("f(\"", 1);
assertNotNull(name);
IASTFunctionCallExpression call = (IASTFunctionCallExpression) name.getParent().getParent();
IASTLiteralExpression arg = (IASTLiteralExpression) call.getArguments()[0];
assertEquals("\"aaamacro\"", arg.toString());
}
}
public void testStructureDef() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct A; \r\n"); //$NON-NLS-1$