aboutsummaryrefslogtreecommitdiffstats
path: root/test/junit/com/sun/gluegen/PCPPTest.java
blob: c086c47f4bb27ea42215acc881028a99d6633d2d (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.sun.gluegen;

import com.sun.gluegen.pcpp.PCPP;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collections;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * serves mainly as entry point for debugging purposes.
 * @author Michael Bien
 */
public class PCPPTest {

    @Test
    public void pcppTest() throws FileNotFoundException, IOException {
        
        PCPP pp = new PCPP(Collections.<String>emptyList());
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        pp.setOut(output);

        String filename = "pcpptest.h";
        String filepath = BuildUtil.path + "/" + filename;

        pp.run(new BufferedReader(new FileReader(filepath)), filename);

        String expected =   "# 1 \"pcpptest.h\""+
                            "# define CL_SCHAR_MIN (-127-1)"+
                            " cl_char  __attribute__(( aligned(2))) s[ 2];"+
                            "# 7 \"pcpptest.h\"";
        output.flush();
        String result = output.toString();
        output.close();

        assertEquals(killWhitespace(expected), killWhitespace(result));

    }

    private String killWhitespace(String a) {
        return a.replaceAll("\\p{javaWhitespace}+", "");
    }


}