aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShevek <[email protected]>2014-12-30 19:10:15 -0800
committerShevek <[email protected]>2014-12-30 19:10:15 -0800
commit75c73f55df6f75a509d4b9699f774167a270d493 (patch)
tree270fc4c3547e477a973a60196401135b413e3bc3
parentf511c467c74077d4254ebc69656edf2d818030dc (diff)
Add extra test from #25.
-rw-r--r--build.gradle2
-rw-r--r--src/test/java/org/anarres/cpp/TokenPastingWhitespaceTest.java43
2 files changed, 44 insertions, 1 deletions
diff --git a/build.gradle b/build.gradle
index cbef726..c3813f8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,7 +22,7 @@ dependencies {
runtime 'org.slf4j:slf4j-simple:1.7.7'
- // testCompile 'com.google.guava:guava:18.0'
+ testCompile 'com.google.guava:guava:18.0'
}
velocity {
diff --git a/src/test/java/org/anarres/cpp/TokenPastingWhitespaceTest.java b/src/test/java/org/anarres/cpp/TokenPastingWhitespaceTest.java
new file mode 100644
index 0000000..2e6a2b5
--- /dev/null
+++ b/src/test/java/org/anarres/cpp/TokenPastingWhitespaceTest.java
@@ -0,0 +1,43 @@
+package org.anarres.cpp;
+
+import com.google.common.io.CharStreams;
+import java.io.IOException;
+import java.io.Reader;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ * https://github.com/shevek/jcpp/issues/25
+ *
+ * @author shevek
+ */
+public class TokenPastingWhitespaceTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TokenPastingWhitespaceTest.class);
+
+ @Test
+ public void testWhitespacePasting() throws IOException {
+ Preprocessor pp = new Preprocessor();
+ 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));
+ Reader r = new CppReader(pp);
+ String text = CharStreams.toString(r).trim();
+ LOG.info("Output is:\n" + text);
+ assertEquals("one_two_good\n"
+ + "one_two_bad\n"
+ + "\n"
+ + "one_good\n"
+ + "one_bad", text);
+ }
+}