From a5266b20b5cd2dbdc5db330b12a1387ac9d2dbb8 Mon Sep 17 00:00:00 2001 From: Sebastian Zarnekow Date: Mon, 4 May 2020 08:53:09 +0200 Subject: [PATCH] Reproducible example for https://github.com/phax/ParserGeneratorCC/issues/26 Signed-off-by: Sebastian Zarnekow --- src/main/javacc/ConditionParser.jj | 2 +- .../helger/pgcc/utils/ConditionParserTest.java | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/javacc/ConditionParser.jj b/src/main/javacc/ConditionParser.jj index b72c88fcc..3e458cd68 100644 --- a/src/main/javacc/ConditionParser.jj +++ b/src/main/javacc/ConditionParser.jj @@ -38,7 +38,7 @@ */ options { - JAVA_UNICODE_ESCAPE = true; + JAVA_UNICODE_ESCAPE = false; } PARSER_BEGIN(ConditionParser) diff --git a/src/test/java/com/helger/pgcc/utils/ConditionParserTest.java b/src/test/java/com/helger/pgcc/utils/ConditionParserTest.java index ed034b63a..1ea2af6ea 100644 --- a/src/test/java/com/helger/pgcc/utils/ConditionParserTest.java +++ b/src/test/java/com/helger/pgcc/utils/ConditionParserTest.java @@ -35,6 +35,7 @@ import static org.junit.Assert.assertEquals; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -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 values = new HashMap <> (); values.put ("F", Boolean.FALSE); values.put ("T", Boolean.TRUE); + _test(input, values, expectedValue); + } + + private static void _test(String input, Map values, boolean expectedValue) throws ParseException { + final ConditionParser cp = new ConditionParser (input); final boolean value = cp.CompilationUnit (values); assertEquals (Boolean.valueOf (expectedValue), Boolean.valueOf (value)); } @@ -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); + } }