1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
public class DoubleTest
{
private double[] check = new double[6];
public DoubleTest()
{
}
private boolean mixedcheckedRadians(int i0, int i1, double d0, double d1, int i2, int i3, double d2, double d3, double d4, int i4, int i5, double d5)
{
if (!(d0 == Math.toRadians(check[0])))
{
System.out.println("mixedcheckedRadians d0 double mismatch:" + d0 + " expected:" + Math.toRadians(check[0]) + ")");
return false;
}
if (!(d1 == Math.toRadians(check[1])))
{
System.out.println("mixedcheckedRadians d1 double mismatch:" + d1 + " expected:" + Math.toRadians(check[1]) + ")");
return false;
}
if (!(d2 == Math.toRadians(check[2])))
{
System.out.println("mixedcheckedRadians d2 double mismatch:" + d2 + " expected:" + Math.toRadians(check[2]) + ")");
return false;
}
if (!(d3 == Math.toRadians(check[3])))
{
System.out.println("mixedcheckedRadians d3 double mismatch:" + d3 + " expected:" + Math.toRadians(check[3]) + ")");
return false;
}
if (!(d4 == Math.toRadians(check[4])))
{
System.out.println("mixedcheckedRadians d4 double mismatch:" + d4 + " expected:" + Math.toRadians(check[4]) + ")");
return false;
}
if (!(d5 == Math.toRadians(check[5])))
{
System.out.println("mixedcheckedRadians d5 double mismatch:" + d5 + " expected:" + Math.toRadians(check[5]) + ")");
return false;
}
return true;
}
public void test(long loops)
{
System.out.println(". ");
long i = 0;
for (; i < loops; i++)
{
double d0 = Math.random() * 1000;
double d1 = Math.random() * 1000;
double d2 = Math.random() * 1000;
double d3 = Math.random() * 1000;
double d4 = Math.random() * 1000;
double d5 = Math.random() * 1000;
check[0] = d0;
check[1] = d1;
check[2] = d2;
check[3] = d3;
check[4] = d4;
check[5] = d5;
int i0 = (int) (Math.random() * 1000);
int i1 = (int) (Math.random() * 1000);
int i2 = (int) (Math.random() * 1000);
int i3 = (int) (Math.random() * 1000);
int i4 = (int) (Math.random() * 1000);
int i5 = (int) (Math.random() * 1000);
if (!mixedcheckedRadians(
(i0 > 300) ? -i0 : i0 + 15,
(i1 < 800 ) ? i1 + 1000 : i1,
Math.toRadians(d0),
Math.toRadians(d1),
(i2 == 0) ? -300 : -2,
(i3 + 60 > 80 ) ? -i3 - 30 : i3 + 500,
Math.toRadians(d2),
Math.toRadians(d3),
Math.toRadians(d4),
i4,
(i5 > i4) ? (i5 - i4) : (i5 + i4),
Math.toRadians(d5)))
break;
}
}
/**
* @param args
*/
public static void main(String[] args)
{
long outerLoop = 50;
long innerLoop = 10000;
if (args.length == 2)
{
outerLoop = Long.parseLong(args[0]);
innerLoop = Long.parseLong(args[1]);
}
System.out.println("starting DoubleTest with outer loop:" + outerLoop + " and inner loop:" + innerLoop);
System.out.println("starting at "+new Date(System.currentTimeMillis()).toGMTString());
for (int i = 0; i < outerLoop; i++)
{
DoubleTest testClass = new DoubleTest();
testClass.test(innerLoop, 1);
}
System.out.println("");
System.out.println("ended DoubleTest");
System.out.println("ending at "+new Date(System.currentTimeMillis()).toGMTString());
}
} |
Partager