diff options
Diffstat (limited to 'src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java')
-rw-r--r-- | src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java b/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java new file mode 100644 index 0000000..756425b --- /dev/null +++ b/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java @@ -0,0 +1,55 @@ +package com.jogamp.gluegen.jcpp; + +import com.jogamp.common.util.IOUtil; + +import java.io.IOException; +import java.io.Reader; + +import org.junit.Test; + +import com.jogamp.gluegen.Logging; +import com.jogamp.gluegen.Logging.LoggerIf; + +import static org.junit.Assert.*; + +/** + * https://github.com/shevek/jcpp/issues/25 + * + * @author shevek + */ +public class TokenPastingWhitespaceTest { + + private static final LoggerIf LOG = Logging.getLogger(TokenPastingWhitespaceTest.class); + + @Test + public void test01WhitespacePasting() throws IOException { + final Preprocessor pp = new Preprocessor(); + testWhitespacePastingImpl(pp); + } + void testWhitespacePastingImpl(final Preprocessor pp) throws IOException { + pp.addInput(new StringLexerSource( + "#define ONE(arg) one_##arg\n" + + "#define TWO(arg) ONE(two_##arg)\n" + + "\n" + + "TWO(good)\n" + + "TWO( /* evil newline */\n" + + " bad)\n" + + "\n" + + "ONE(good)\n" + + "ONE( /* evil newline */\n" + + " bad)\n", true)); + final Reader r = new CppReader(pp); + final String text = IOUtil.appendCharStream(new StringBuilder(), r).toString().trim(); + LOG.info("Output is:\n" + text); + assertEquals("one_two_good\n" + + "one_two_bad\n" + + "\n" + + "one_good\n" + + "one_bad", text); + } + + public static void main(final String args[]) throws IOException { + final String tstname = TokenPastingWhitespaceTest.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} |