aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java
blob: df7ffb7ccc15d2b20c4da3091a5d0a2d98c393b3 (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
35
package org.anarres.cpp;

import com.google.common.io.CharStreams;
import java.io.BufferedReader;
import java.io.File;
import java.io.Reader;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;

/**
 *
 * @author shevek
 */
public class IncludeAbsoluteTest {

    private static final Logger LOG = LoggerFactory.getLogger(IncludeAbsoluteTest.class);

    @Test
    public void testAbsoluteInclude() throws Exception {
        File file = new File("build/resources/test/absolute.h");
        assertTrue(file.exists());

        String input = "#include <" + file.getAbsolutePath() + ">\n";
        LOG.info("Input: " + input);
        Preprocessor pp = new Preprocessor();
        pp.addInput(new StringLexerSource(input, true));
        Reader r = new CppReader(pp);
        String output = CharStreams.toString(r);
        r.close();
        LOG.info("Output: " + output);
        assertTrue(output.contains("absolute-result"));
    }
}