[apex] Add test case for #5333

This commit is contained in:
Andreas Dangel
2024-11-14 18:16:06 +01:00
parent 991bc2c41d
commit 509452577d
2 changed files with 10 additions and 1 deletions

View File

@ -66,4 +66,12 @@ class ApexCommentTest extends ApexParserTestBase {
ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTFormalComment.class).first();
assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage());
}
@Test
void fileWithUnicodeEscapes() {
ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n"
+ "class MyClass { String s = 'Fran\\u00E7ois'; }");
ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTFormalComment.class).first();
assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage());
}
}

View File

@ -57,6 +57,7 @@ class ApexLexerTest {
@Test
void testLexerUnicodeEscapes() {
String s = "'Fran\\u00E7ois'";
// note: with apex-parser 4.3.1, no errors are reported anymore
assertEquals(2, getLexingErrors(CharStreams.fromString(s)));
assertEquals(0, getLexingErrors(new CaseInsensitiveInputStream(CharStreams.fromString(s))));
}
@ -71,7 +72,7 @@ class ApexLexerTest {
return errorListener.getErrorCount();
}
static class ErrorListener extends BaseErrorListener {
private static class ErrorListener extends BaseErrorListener {
private int errorCount = 0;
@Override