Skip to content

Commit

Permalink
Reproducible example for tulipcc#26
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Zarnekow <[email protected]>
  • Loading branch information
szarnekow committed May 4, 2020
1 parent e6a0b4f commit a5266b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/javacc/ConditionParser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/

options {
JAVA_UNICODE_ESCAPE = true;
JAVA_UNICODE_ESCAPE = false;
}

PARSER_BEGIN(ConditionParser)
Expand Down
17 changes: 16 additions & 1 deletion src/test/java/com/helger/pgcc/utils/ConditionParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -49,10 +50,14 @@ public final class ConditionParserTest
{
private static void _test (final String input, final boolean expectedValue) throws ParseException
{
final ConditionParser cp = new ConditionParser (input);
final Map <String, Object> values = new HashMap <> ();
values.put ("F", Boolean.FALSE);
values.put ("T", Boolean.TRUE);
_test(input, values, expectedValue);
}

private static void _test(String input, Map<String, Object> values, boolean expectedValue) throws ParseException {
final ConditionParser cp = new ConditionParser (input);
final boolean value = cp.CompilationUnit (values);
assertEquals (Boolean.valueOf (expectedValue), Boolean.valueOf (value));
}
Expand All @@ -69,4 +74,14 @@ public void testBasic () throws ParseException
_test ("T && T", true);
_test ("unknown", false);
}

@Test
public void testBufferExpansion () throws ParseException
{
char[] a = new char[2048 - 4 /* open + close of the comment */];
Arrays.fill(a, 'a');
char[] b = new char[4096 - 4 + 1 /* force the buffer to expand and wrap around */];
Arrays.fill(b, 'b');
_test (String.format("/*%s*/\n/*%s*/\nT || F", String.valueOf(a), String.valueOf(b)), true);
}
}

0 comments on commit a5266b2

Please sign in to comment.