mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer:
This commit is contained in:
parent
4ff57e8849
commit
7dd6d81653
1 changed files with 71 additions and 1 deletions
|
@ -38,6 +38,8 @@ public class ScannerFailedTest extends ScannerTestCase {
|
|||
TestSuite suite = new TestSuite();
|
||||
|
||||
suite.addTest( new ScannerFailedTest( "testBug36475" ) );
|
||||
suite.addTest( new ScannerFailedTest( "testBug36509" ) );
|
||||
suite.addTest( new ScannerFailedTest( "testBug36521" ) );
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
@ -65,6 +67,74 @@ public class ScannerFailedTest extends ScannerTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
if( testPassed )
|
||||
fail( "The expected error did not occur." );
|
||||
}
|
||||
public void testBug36509() throws Exception
|
||||
{
|
||||
boolean testPassed = false;
|
||||
|
||||
try{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write("#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\\n");
|
||||
writer.write(" x ## s, x ## t) \n");
|
||||
|
||||
initializeScanner( writer.toString() );
|
||||
//printf("x" "1" "=%d, x" "2" "= %s", x1, x2);
|
||||
validateIdentifier( "printf" );
|
||||
validateToken( Token.tLPAREN );
|
||||
validateString("x");
|
||||
validateString("1");
|
||||
validateString("= %d, x");
|
||||
validateString("2");
|
||||
validateString("= %s");
|
||||
validateToken(Token.tCOMMA);
|
||||
validateIdentifier("x1");
|
||||
validateToken(Token.tCOMMA);
|
||||
validateIdentifier("x2");
|
||||
validateToken(Token.tRPAREN);
|
||||
validateToken(Token.tSEMI);
|
||||
|
||||
testPassed = true;
|
||||
}
|
||||
catch( Throwable e )
|
||||
{
|
||||
if( !(e instanceof AssertionFailedError) ){
|
||||
fail( "Unexpected Error: " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
if( testPassed )
|
||||
fail( "The expected error did not occur." );
|
||||
}
|
||||
public void testBug36521() throws Exception
|
||||
{
|
||||
boolean testPassed = false;
|
||||
|
||||
try{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write("#define str(s) # s\n");
|
||||
writer.write("fputs(str(strncmp(\"abc\\0d\", \"abc\", \'\\4\')\n");
|
||||
writer.write(" == 0) str(: @\\n), s);\n");
|
||||
|
||||
initializeScanner( writer.toString() );
|
||||
validateIdentifier("fputs");
|
||||
validateToken(Token.tLPAREN);
|
||||
validateString("strncmp(\\\"abc\\\\0d\\\", \\\"abc\\\", '\\\\4') == 0");
|
||||
validateString(": @\\n");
|
||||
validateToken(Token.tCOMMA);
|
||||
validateIdentifier("s");
|
||||
validateToken(Token.tRPAREN);
|
||||
validateToken(Token.tSEMI);
|
||||
|
||||
testPassed = true;
|
||||
}
|
||||
catch( ScannerException e )
|
||||
{
|
||||
if( !e.getMessage().equals( "Improper use of macro str" ) )
|
||||
fail( "Unexpected Error: " + e.getMessage() );
|
||||
}
|
||||
|
||||
if( testPassed )
|
||||
fail( "The expected error did not occur." );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue