mirror of
https://github.com/go-i2p/gojava.git
synced 2025-07-04 10:16:23 -04:00
Initial commit with a working build.
Some of the tests are failing.
This commit is contained in:
85
MoreAsserts.java
Normal file
85
MoreAsserts.java
Normal file
@ -0,0 +1,85 @@
|
||||
package go;
|
||||
|
||||
import go.LoadJNI;
|
||||
import java.util.Arrays;
|
||||
import java.lang.Math;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import go.SeqTest;
|
||||
|
||||
public class MoreAsserts {
|
||||
public static void assertTrue(String msg, boolean condition) {
|
||||
if (!condition) {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertTrue(boolean condition) {
|
||||
if (!condition) {
|
||||
throw new RuntimeException("assert failed");
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertEquals(int expected, int actual) {
|
||||
assertTrue(expected == actual);
|
||||
}
|
||||
|
||||
public static void assertFalse(boolean condition) {
|
||||
assertTrue(!condition);
|
||||
}
|
||||
|
||||
public static void assertFalse(String msg, boolean condition) {
|
||||
assertTrue(msg, !condition);
|
||||
}
|
||||
|
||||
public static void assertEquals(String msg, int expected, int actual) {
|
||||
assertTrue(msg, expected == actual);
|
||||
}
|
||||
|
||||
public static void assertEquals(String msg, long expected, long actual) {
|
||||
assertTrue(msg, expected == actual);
|
||||
}
|
||||
|
||||
public static void assertEquals(String msg, String expected, String actual) {
|
||||
assertTrue(msg, expected == actual);
|
||||
}
|
||||
|
||||
public static void assertEquals(String msg, boolean expected, boolean actual) {
|
||||
assertTrue(msg, expected == actual);
|
||||
}
|
||||
public static void assertEquals(String msg, byte[] expected, byte[] actual) {
|
||||
assertTrue(msg, Arrays.equals(expected, actual));
|
||||
}
|
||||
|
||||
public static void assertEquals(String msg, double expected, double actual, double epsilon) {
|
||||
assertTrue(msg, Math.abs(expected - actual) < epsilon);
|
||||
}
|
||||
|
||||
public static void assertEquals(String msg, Object expected, Object actual) {
|
||||
assertTrue(msg, (expected == null && actual == null) || (expected.equals(actual)));
|
||||
}
|
||||
|
||||
public static void fail(String msg) {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SeqTest test = new SeqTest();
|
||||
Class c = test.getClass();
|
||||
for (Method method : c.getDeclaredMethods()) {
|
||||
if (!method.getName().startsWith("test")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.print(method.getName());
|
||||
try {
|
||||
method.invoke(test);
|
||||
System.out.println(" PASS");
|
||||
} catch (Exception ex) {
|
||||
System.out.println(" FAIL");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user