aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-08-08 14:24:52 +0200
committerSven Gothel <[email protected]>2023-08-08 14:24:52 +0200
commitdbbc1741f9b564de87d0924017fac25aa185f9d6 (patch)
tree6adce9651f8efcfa6f77c82ab81ff1d23eaa80a6
parent29198e4cd9a5bd8d1bb72569ea10394b8ace9ebb (diff)
Patch merged new upstream unit tests (2)
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/BuildMetadataTest.java33
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/PragmaTest.java29
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/RegressionTest.java43
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/VaArgsPastingTest.java17
4 files changed, 60 insertions, 62 deletions
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/BuildMetadataTest.java b/src/test/java/com/jogamp/gluegen/jcpp/BuildMetadataTest.java
deleted file mode 100644
index 42dc071..0000000
--- a/src/test/java/com/jogamp/gluegen/jcpp/BuildMetadataTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.anarres.cpp;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Resources;
-import java.net.URL;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * @author shevek
- */
-public class BuildMetadataTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(BuildMetadataTest.class);
-
- @Test
- public void testProperties() throws Exception {
- URL url = Resources.getResource("META-INF/jcpp.properties");
- String text = Resources.asCharSource(url, Charsets.ISO_8859_1).read();
- LOG.info("Metadata is " + text);
- }
-
- @Test
- public void testMetadata() throws Exception {
- BuildMetadata metadata = BuildMetadata.getInstance();
- LOG.info("Version is " + metadata.getVersion());
- LOG.info("BuildDate is " + metadata.getBuildDate());
- LOG.info("ChangeId is " + metadata.getChangeId());
- }
-
-}
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/PragmaTest.java b/src/test/java/com/jogamp/gluegen/jcpp/PragmaTest.java
index 342bd52..8c82743 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/PragmaTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/PragmaTest.java
@@ -3,37 +3,48 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package org.anarres.cpp;
+package com.jogamp.gluegen.jcpp;
import com.google.common.base.Charsets;
import com.google.common.io.CharSource;
import com.google.common.io.CharStreams;
import com.google.common.io.Files;
import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.jogamp.gluegen.Logging;
+import com.jogamp.gluegen.Logging.LoggerIf;
+import com.jogamp.gluegen.test.junit.generation.BuildEnvironment;
+import com.jogamp.junit.util.SingletonJunitCase;
import static org.junit.Assert.*;
/**
*
* @author shevek
*/
-public class PragmaTest {
+public class PragmaTest extends SingletonJunitCase {
- private static final Logger LOG = LoggerFactory.getLogger(PragmaTest.class);
+ private static final LoggerIf LOG = Logging.getLogger(PragmaTest.class);
@Test
public void testPragma() throws Exception {
- File file = new File("build/resources/test/pragma.c");
+ LOG.setLevel(Level.INFO);
+ final File file = new File(BuildEnvironment.gluegenRoot+"/jcpp/src/test/resources/pragma.c");
assertTrue(file.exists());
- CharSource source = Files.asCharSource(file, Charsets.UTF_8);
- CppReader r = new CppReader(source.openBufferedStream());
+ final CharSource source = Files.asCharSource(file, Charsets.UTF_8);
+ final CppReader r = new CppReader(source.openBufferedStream());
r.getPreprocessor().setListener(new DefaultPreprocessorListener());
- String output = CharStreams.toString(r);
+ final String output = CharStreams.toString(r);
r.close();
LOG.info("Output: " + output);
// assertTrue(output.contains("absolute-result"));
}
+
+ public static void main(final String args[]) throws IOException {
+ final String tstname = PragmaTest.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
}
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/RegressionTest.java b/src/test/java/com/jogamp/gluegen/jcpp/RegressionTest.java
index 3ce3568..cc3d886 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/RegressionTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/RegressionTest.java
@@ -3,21 +3,26 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package org.anarres.cpp;
+package com.jogamp.gluegen.jcpp;
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import com.google.common.io.Files;
import com.google.common.io.PatternFilenameFilter;
import java.io.File;
+import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.jogamp.gluegen.Logging;
+import com.jogamp.gluegen.Logging.LoggerIf;
+import com.jogamp.gluegen.test.junit.generation.BuildEnvironment;
+import com.jogamp.junit.util.SingletonJunitCase;
import static org.junit.Assert.assertEquals;
/**
@@ -25,18 +30,18 @@ import static org.junit.Assert.assertEquals;
* @author shevek
*/
@RunWith(Parameterized.class)
-public class RegressionTest {
+public class RegressionTest extends SingletonJunitCase {
- private static final Logger LOG = LoggerFactory.getLogger(RegressionTest.class);
+ private static final LoggerIf LOG = Logging.getLogger(RegressionTest.class);
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> data() throws Exception {
- List<Object[]> out = new ArrayList<Object[]>();
+ final List<Object[]> out = new ArrayList<Object[]>();
- File dir = new File("build/resources/test/regression");
- for (File inFile : dir.listFiles(new PatternFilenameFilter(".*\\.in"))) {
- String name = Files.getNameWithoutExtension(inFile.getName());
- File outFile = new File(dir, name + ".out");
+ final File dir = new File(BuildEnvironment.gluegenRoot+"/jcpp/src/test/resources/regression");
+ for (final File inFile : dir.listFiles(new PatternFilenameFilter(".*\\.in"))) {
+ final String name = Files.getNameWithoutExtension(inFile.getName());
+ final File outFile = new File(dir, name + ".out");
out.add(new Object[]{name, inFile, outFile});
}
@@ -47,7 +52,7 @@ public class RegressionTest {
private final File inFile;
private final File outFile;
- public RegressionTest(String name, File inFile, File outFile) {
+ public RegressionTest(final String name, final File inFile, final File outFile) {
this.name = name;
this.inFile = inFile;
this.outFile = outFile;
@@ -55,16 +60,24 @@ public class RegressionTest {
@Test
public void testRegression() throws Exception {
- String inText = Files.toString(inFile, Charsets.UTF_8);
+ LOG.setLevel(Level.INFO);
+ @SuppressWarnings("deprecation")
+ final String inText = Files.toString(inFile, Charsets.UTF_8);
LOG.info("Read " + name + ":\n" + inText);
- CppReader cppReader = new CppReader(new StringReader(inText));
- String cppText = CharStreams.toString(cppReader);
+ final CppReader cppReader = new CppReader(new StringReader(inText));
+ final String cppText = CharStreams.toString(cppReader);
LOG.info("Generated " + name + ":\n" + cppText);
if (outFile.exists()) {
- String outText = Files.toString(outFile, Charsets.UTF_8);
+ @SuppressWarnings("deprecation")
+ final String outText = Files.toString(outFile, Charsets.UTF_8);
LOG.info("Expected " + name + ":\n" + outText);
assertEquals(outText, inText);
}
}
+
+ public static void main(final String args[]) throws IOException {
+ final String tstname = RegressionTest.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
}
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/VaArgsPastingTest.java b/src/test/java/com/jogamp/gluegen/jcpp/VaArgsPastingTest.java
index f1bcbcd..8925014 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/VaArgsPastingTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/VaArgsPastingTest.java
@@ -3,23 +3,24 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package org.anarres.cpp;
+package com.jogamp.gluegen.jcpp;
import com.google.common.io.CharStreams;
import java.io.IOException;
import java.io.Reader;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.jogamp.gluegen.Logging;
+import com.jogamp.gluegen.Logging.LoggerIf;
+import com.jogamp.junit.util.SingletonJunitCase;
import static org.junit.Assert.*;
/**
*
* @author shevek
*/
-public class VaArgsPastingTest {
+public class VaArgsPastingTest extends SingletonJunitCase {
- private static final Logger LOG = LoggerFactory.getLogger(VaArgsPastingTest.class);
+ private static final LoggerIf LOG = Logging.getLogger(VaArgsPastingTest.class);
@Test
public void testWhitespacePasting() throws IOException {
@@ -60,4 +61,10 @@ public class VaArgsPastingTest {
+ "foo(a,b) // PASTE_VAARGS 2\n"
+ "foo(a) // PASTE_VAARGS 1", output);
}
+
+
+ public static void main(final String args[]) throws IOException {
+ final String tstname = VaArgsPastingTest.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
}