From 4669dce04c31e5fc2a32837099e5c47624d90fba Mon Sep 17 00:00:00 2001
From: Michael Bien <mbien@fh-landshut.de>
Date: Sat, 20 Feb 2010 23:56:25 +0100
Subject: added PCPPTest.

---
 test/junit/com/sun/gluegen/PCPPTest.java | 49 ++++++++++++++++++++++++++++++++
 test/junit/com/sun/gluegen/pcpptest.h    |  6 ++++
 2 files changed, 55 insertions(+)
 create mode 100644 test/junit/com/sun/gluegen/PCPPTest.java
 create mode 100644 test/junit/com/sun/gluegen/pcpptest.h

(limited to 'test/junit/com/sun/gluegen')

diff --git a/test/junit/com/sun/gluegen/PCPPTest.java b/test/junit/com/sun/gluegen/PCPPTest.java
new file mode 100644
index 0000000..c086c47
--- /dev/null
+++ b/test/junit/com/sun/gluegen/PCPPTest.java
@@ -0,0 +1,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}+", "");
+    }
+
+
+}
diff --git a/test/junit/com/sun/gluegen/pcpptest.h b/test/junit/com/sun/gluegen/pcpptest.h
new file mode 100644
index 0000000..58b8935
--- /dev/null
+++ b/test/junit/com/sun/gluegen/pcpptest.h
@@ -0,0 +1,6 @@
+
+#define CL_SCHAR_MIN     (-127-1)
+#define CL_ALIGNED(_x)   __attribute__ ((aligned(_x)))
+
+cl_char  CL_ALIGNED(2) s[2];
+
-- 
cgit v1.2.3