summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorShevek <[email protected]>2014-09-09 04:16:03 -0700
committerShevek <[email protected]>2014-09-09 04:16:03 -0700
commitb6a44c31015a71f4624b3ab0b36503a90023c244 (patch)
tree70e953547493a674053926a1c2895678474bb3c0 /src/test
parent09e951892e640874756690d3e9f7d07613b4f67b (diff)
Fix #16: NPE on unterminated ifdef.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/anarres/cpp/PreprocessorTest.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/test/java/org/anarres/cpp/PreprocessorTest.java b/src/test/java/org/anarres/cpp/PreprocessorTest.java
index c8bd7a1..7103cba 100644
--- a/src/test/java/org/anarres/cpp/PreprocessorTest.java
+++ b/src/test/java/org/anarres/cpp/PreprocessorTest.java
@@ -4,6 +4,8 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Test;
import static org.anarres.cpp.Token.*;
@@ -11,6 +13,8 @@ import static org.junit.Assert.*;
public class PreprocessorTest {
+ private static final Log LOG = LogFactory.getLog(PreprocessorTest.class);
+
private OutputStreamWriter writer;
private Preprocessor p;
@@ -153,18 +157,31 @@ public class PreprocessorTest {
Token t;
do {
t = p.token();
- System.out.println("Remaining token " + t);
+ LOG.warn("Remaining token " + t);
+ } while (t.getType() != EOF);
+ }
+
+ @Test
+ public void testPreprocessorUnterminated() throws Exception {
+ testInput("#ifndef X\na\n#else\nb\n"); // Bug #16
+
+ writer.close();
+
+ Token t;
+ do {
+ t = p.token();
+ LOG.warn("Remaining token " + t);
} while (t.getType() != EOF);
}
private void testInput(String in, Object... out)
throws Exception {
- System.out.print("Input: " + in);
+ LOG.info("Input: " + in);
writer.write(in);
writer.flush();
for (int i = 0; i < out.length; i++) {
Token t = p.token();
- System.out.println(t);
+ LOG.info(t);
Object v = out[i];
if (v instanceof String) {
if (t.getType() != STRING)