aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-27 04:59:48 +0200
committerSven Gothel <[email protected]>2011-10-27 04:59:48 +0200
commitef30b77fab27262f8b5ef3f98880c0caec30bab5 (patch)
treec6242d5c742afdd3d5815f490b5ceb61a871423e
parentfa5969168440a01fab814df78a3d23d10c27f72d (diff)
Fix VersionNumber cstr w/ string parsing: cutt-off non-digit-parts, suppress exceptions
-rwxr-xr-xmake/scripts/runtest.sh6
-rw-r--r--src/java/com/jogamp/common/util/VersionNumber.java41
-rw-r--r--src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java7
-rw-r--r--src/junit/com/jogamp/common/util/TestPlatform01.java19
4 files changed, 50 insertions, 23 deletions
diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh
index 31de364..dc3f6a5 100755
--- a/make/scripts/runtest.sh
+++ b/make/scripts/runtest.sh
@@ -58,10 +58,10 @@ function onetest() {
#onetest com.jogamp.common.util.LongIntHashMapTest 2>&1 | tee -a $LOG
#onetest com.jogamp.common.nio.TestBuffersFloatDoubleConversion 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.PCPPTest 2>&1 | tee -a $LOG
-#onetest com.jogamp.gluegen.test.TestPointerBufferEndian 2>&1 | tee -a $LOG
+#onetest com.jogamp.common.nio.TestPointerBufferEndian 2>&1 | tee -a $LOG
#onetest com.jogamp.common.nio.TestStructAccessorEndian 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter 2>&1 | tee -a $LOG
-onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG
-#onetest com.jogamp.common.util.TestPlatform01 2>&1 | tee -a $LOG
+#onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG
+onetest com.jogamp.common.util.TestPlatform01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestIOUtil01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestTempJarCache 2>&1 | tee -a $LOG
diff --git a/src/java/com/jogamp/common/util/VersionNumber.java b/src/java/com/jogamp/common/util/VersionNumber.java
index 57c83da..1225231 100644
--- a/src/java/com/jogamp/common/util/VersionNumber.java
+++ b/src/java/com/jogamp/common/util/VersionNumber.java
@@ -47,26 +47,27 @@ public class VersionNumber implements Comparable {
* @param delim the delimiter, e.g. "."
*/
public VersionNumber(String versionString, String delim) {
- try {
- StringTokenizer tok = new StringTokenizer(versionString, delim);
- if (!tok.hasMoreTokens()) {
- major = 0;
- return;
- }
- major = Integer.valueOf(tok.nextToken()).intValue();
- if (!tok.hasMoreTokens()) {
- minor = 0;
- return;
- }
- minor = Integer.valueOf(tok.nextToken()).intValue();
- if (!tok.hasMoreTokens()) {
- sub = 0;
- return;
- }
- sub = Integer.valueOf(tok.nextToken()).intValue();
- } catch (Exception e) {
- throw new IllegalArgumentException("version <"+versionString+">, delim <"+delim+">", e);
+ final java.util.regex.Pattern nonDigitsCutOff = java.util.regex.Pattern.compile("\\D.*");
+ major = 0;
+ minor = 0;
+ sub = 0;
+
+ StringTokenizer tok = new StringTokenizer(versionString, delim);
+ if (tok.hasMoreTokens()) {
+ try {
+ major = Integer.parseInt(nonDigitsCutOff.matcher(tok.nextToken()).replaceAll(""));
+ } catch (NumberFormatException e) { }
}
+ if (tok.hasMoreTokens()) {
+ try {
+ minor = Integer.parseInt(nonDigitsCutOff.matcher(tok.nextToken()).replaceAll(""));
+ } catch (NumberFormatException e) { }
+ }
+ if (tok.hasMoreTokens()) {
+ try {
+ sub = Integer.parseInt(nonDigitsCutOff.matcher(tok.nextToken()).replaceAll(""));
+ } catch (NumberFormatException e) { }
+ }
}
protected VersionNumber() { }
@@ -86,7 +87,7 @@ public class VersionNumber implements Comparable {
public final int compareTo(Object o) {
if ( ! ( o instanceof VersionNumber ) ) {
- Class c = (null != o) ? o.getClass() : null ;
+ Class<?> c = (null != o) ? o.getClass() : null ;
throw new ClassCastException("Not a Capabilities object: " + c);
}
diff --git a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java
index e587acf..43d6a61 100644
--- a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java
+++ b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java
@@ -1,6 +1,8 @@
package com.jogamp.common.nio;
+import java.io.IOException;
+
import com.jogamp.common.os.*;
import org.junit.Assert;
@@ -43,4 +45,9 @@ public class TestPointerBufferEndian {
public void testIndirect () {
testImpl (false);
}
+
+ public static void main(String args[]) throws IOException {
+ String tstname = TestPointerBufferEndian.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
}
diff --git a/src/junit/com/jogamp/common/util/TestPlatform01.java b/src/junit/com/jogamp/common/util/TestPlatform01.java
index 1266c45..c10bf0b 100644
--- a/src/junit/com/jogamp/common/util/TestPlatform01.java
+++ b/src/junit/com/jogamp/common/util/TestPlatform01.java
@@ -37,6 +37,25 @@ import com.jogamp.common.os.Platform;
public class TestPlatform01 {
@Test
+ public void testInfo00() {
+ System.err.println();
+ System.err.println();
+ System.err.println("OS name/type: "+Platform.getOSName()+", "+Platform.getOSType());
+ System.err.println("OS version: "+Platform.getOSVersion()+", "+Platform.getOSVersionNumber());
+ System.err.println();
+ System.err.println("Arch, CPU: "+Platform.getArchName()+", "+Platform.getCPUType()+"/"+Platform.getCPUFamily());
+ System.err.println("OS/Arch: "+Platform.getOSAndArch());
+ System.err.println();
+ System.err.println("Java runtime: "+Platform.getJavaRuntimeName());
+ System.err.println("Java vendor[name/url]: "+Platform.getJavaVendor()+"/"+Platform.getJavaVendorURL());
+ System.err.println("Java version, vm: "+Platform.getJavaVersion()+", "+Platform.getJavaVMName());
+ System.err.println();
+ System.err.println("MD: "+Platform.getMachineDescription());
+ System.err.println();
+ System.err.println();
+ }
+
+ @Test
public void testPageSize01() {
final MachineDescription machine = Platform.getMachineDescription();
final int ps = machine.pageSizeInBytes();