Better error detection in some java testcases

This commit is contained in:
William S Fulton 2014-03-01 16:14:36 +00:00
parent 736c6b953e
commit 09cfc53bdf
6 changed files with 31 additions and 40 deletions

View File

@ -22,8 +22,7 @@ public class dynamic_cast_runme {
// Note it is possible to downcast y with a Java cast.
String a = dynamic_cast.do_test((Bar)y);
if (!a.equals("Bar::test")) {
System.err.println("Failed!");
System.exit(1);
throw new RuntimeException("Failed!");
}
}
}

View File

@ -16,16 +16,16 @@ public class ignore_parameter_runme {
{
// Compilation will ensure the number of arguments and type are correct.
// Then check the return value is the same as the value given to the ignored parameter.
if (!ignore_parameter.jaguar(200, 0.0).equals("hello")) { System.err.println("Runtime Error in jaguar()");}
if (ignore_parameter.lotus("fast", 0.0) != 101) { System.err.println("Runtime Error in lotus()");}
if (ignore_parameter.tvr("fast", 200) != 8.8) { System.err.println("Runtime Error in tvr()");}
if (ignore_parameter.ferrari() != 101) { System.err.println("Runtime Error in ferrari()");}
if (!ignore_parameter.jaguar(200, 0.0).equals("hello")) { throw new RuntimeException("Runtime Error in jaguar()");}
if (ignore_parameter.lotus("fast", 0.0) != 101) { throw new RuntimeException("Runtime Error in lotus()");}
if (ignore_parameter.tvr("fast", 200) != 8.8) { throw new RuntimeException("Runtime Error in tvr()");}
if (ignore_parameter.ferrari() != 101) { throw new RuntimeException("Runtime Error in ferrari()");}
SportsCars sc = new SportsCars();
if (!sc.daimler(200, 0.0).equals("hello")) { System.err.println("Runtime Error in daimler()");}
if (sc.astonmartin("fast", 0.0) != 101) { System.err.println("Runtime Error in astonmartin()");}
if (sc.bugatti("fast", 200) != 8.8) { System.err.println("Runtime Error in bugatti()");}
if (sc.lamborghini() != 101) { System.err.println("Runtime Error in lamborghini()");}
if (!sc.daimler(200, 0.0).equals("hello")) { throw new RuntimeException("Runtime Error in daimler()");}
if (sc.astonmartin("fast", 0.0) != 101) { throw new RuntimeException("Runtime Error in astonmartin()");}
if (sc.bugatti("fast", 200) != 8.8) { throw new RuntimeException("Runtime Error in bugatti()");}
if (sc.lamborghini() != 101) { throw new RuntimeException("Runtime Error in lamborghini()");}
// Check constructors are also generated correctly
MiniCooper mc = new MiniCooper(200, 0.0);

View File

@ -51,7 +51,6 @@ public class java_jnitypes_runme {
}
public static void testFailed(String str) {
System.err.println(str + " test failed");
System.exit(1);
throw new RuntimeException(str + " test failed");
}
}

View File

@ -66,8 +66,7 @@ public class long_long_runme {
long_long.setLl(ll);
long ll_check = long_long.getLl();
if (ll != ll_check) {
System.err.println("Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check);
System.exit(1);
throw new RuntimeException("Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check);
}
}
@ -75,8 +74,7 @@ public class long_long_runme {
long_long.setUll(ull);
BigInteger ull_check = long_long.getUll();
if (ull.compareTo(ull_check) != 0) {
System.err.println("Runtime test using unsigned long long failed. ull=" + ull.toString() + " ull_check=" + ull_check.toString());
System.exit(1);
throw new RuntimeException("Runtime test using unsigned long long failed. ull=" + ull.toString() + " ull_check=" + ull_check.toString());
}
}
}

View File

@ -18,47 +18,47 @@ public class primitive_ref_runme {
public static void main(String argv[]) {
if (primitive_ref.ref_int(3) != 3) {
System.err.println( "ref_int failed!" );
throw new RuntimeException( "ref_int failed!" );
}
if (primitive_ref.ref_uint(3) != 3) {
System.err.println( "ref_uint failed!" );
throw new RuntimeException( "ref_uint failed!" );
}
if (primitive_ref.ref_short((short)3) != 3) {
System.err.println( "ref_short failed!" );
throw new RuntimeException( "ref_short failed!" );
}
if (primitive_ref.ref_ushort(3) != 3) {
System.err.println( "ref_ushort failed!" );
throw new RuntimeException( "ref_ushort failed!" );
}
if (primitive_ref.ref_long(3) != 3) {
System.err.println( "ref_long failed!" );
throw new RuntimeException( "ref_long failed!" );
}
if (primitive_ref.ref_ulong(3) != 3) {
System.err.println( "ref_ulong failed!" );
throw new RuntimeException( "ref_ulong failed!" );
}
if (primitive_ref.ref_schar((byte)3) != 3) {
System.err.println( "ref_schar failed!" );
throw new RuntimeException( "ref_schar failed!" );
}
if (primitive_ref.ref_uchar((short)3) != 3) {
System.err.println( "ref_uchar failed!" );
throw new RuntimeException( "ref_uchar failed!" );
}
if (primitive_ref.ref_bool(true) != true) {
System.err.println( "ref_bool failed!" );
throw new RuntimeException( "ref_bool failed!" );
}
if (primitive_ref.ref_float((float)3.5) != 3.5) {
System.err.println( "ref_float failed!" );
throw new RuntimeException( "ref_float failed!" );
}
if (primitive_ref.ref_double(3.5) != 3.5) {
System.err.println( "ref_double failed!" );
throw new RuntimeException( "ref_double failed!" );
}
if (primitive_ref.ref_char('x') != 'x') {
System.err.println( "ref_char failed!" );
throw new RuntimeException( "ref_char failed!" );
}
if (primitive_ref.ref_longlong(0x123456789ABCDEF0L) != 0x123456789ABCDEF0L) {
System.err.println( "ref_longlong failed!" );
throw new RuntimeException( "ref_longlong failed!" );
}
BigInteger bi = new BigInteger("18446744073709551615"); //0xFFFFFFFFFFFFFFFFL
if (bi.compareTo(primitive_ref.ref_ulonglong(bi)) != 0) {
System.err.println( "ref_ulonglong failed!" );
throw new RuntimeException( "ref_ulonglong failed!" );
}
}
}

View File

@ -34,14 +34,12 @@ public class unions_runme {
eut.getUni().setSmall(small);
short Jill1 = eut.getUni().getSmall().getJill();
if (Jill1 != 200) {
System.err.println("Runtime test1 failed. eut.uni.small.jill=" + Jill1);
System.exit(1);
throw new RuntimeException("Runtime test1 failed. eut.uni.small.jill=" + Jill1);
}
int Num1 = eut.getNumber();
if (Num1 != 1) {
System.err.println("Runtime test2 failed. eut.number=" + Num1);
System.exit(1);
throw new RuntimeException("Runtime test2 failed. eut.number=" + Num1);
}
// Secondly check the BigStruct in EmbeddedUnionTest
@ -49,20 +47,17 @@ public class unions_runme {
eut.getUni().setBig(big);
int Jack1 = eut.getUni().getBig().getJack();
if (Jack1 != 300) {
System.err.println("Runtime test3 failed. eut.uni.big.jack=" + Jack1);
System.exit(1);
throw new RuntimeException("Runtime test3 failed. eut.uni.big.jack=" + Jack1);
}
short Jill2 = eut.getUni().getBig().getSmallstruct().getJill();
if (Jill2 != 200) {
System.err.println("Runtime test4 failed. eut.uni.big.smallstruct.jill=" + Jill2);
System.exit(1);
throw new RuntimeException("Runtime test4 failed. eut.uni.big.smallstruct.jill=" + Jill2);
}
int Num2 = eut.getNumber();
if (Num2 != 2) {
System.err.println("Runtime test5 failed. eut.number=" + Num2);
System.exit(1);
throw new RuntimeException("Runtime test5 failed. eut.number=" + Num2);
}
}
}