diff options
author | Shevek <[email protected]> | 2015-01-01 11:06:48 -0800 |
---|---|---|
committer | Shevek <[email protected]> | 2015-01-01 11:06:48 -0800 |
commit | 34f2c3f91099b19efc4ce4c5d26b8b8eedfb3aa8 (patch) | |
tree | 5d415c0d04cf57d9e2208e92a0f9725831f601cc /src/test | |
parent | 3e0f34f77c1ea1f9b27b097efaa8bcf3dee19e4b (diff) |
Fix #21: Allow including absolute files.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java b/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java new file mode 100644 index 0000000..1a20a70 --- /dev/null +++ b/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java @@ -0,0 +1,34 @@ +package org.anarres.cpp; + +import java.io.BufferedReader; +import java.io.Reader; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author shevek + */ +public class IncludeAbsoluteTest { + + private static final Logger LOG = LoggerFactory.getLogger(IncludeAbsoluteTest.class); + + // TODO: Rewrite this test to get the CWD and read a file with known content in the test suite. + // Guava (available in test suite) can map a URL to a File resource. + @Test + public void testAbsoluteInclude() throws Exception { + Preprocessor pp = new Preprocessor(); + pp.getSystemIncludePath().add("/usr/include"); + pp.addInput(new StringLexerSource( + "#include </usr/include/features.h>\n" + + "", true)); + Reader r = new CppReader(pp); + // This will error if the file isn't found. + BufferedReader br = new BufferedReader(r); + for (int i = 0; i < 10; i++) { + LOG.info(br.readLine()); + } + br.close(); + } +} |