aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java
blob: 1a20a707f50598ce6c445ba8684bff6cccd93c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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();
    }
}