[llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/ArrayCopy.java
Alkis Evlogimenos
alkis at cs.uiuc.edu
Wed Feb 2 10:40:19 PST 2005
Changes in directory llvm-java/test/Programs/SingleSource/UnitTests:
ArrayCopy.java updated: 1.2 -> 1.3
---
Log message:
Make ArrayCopy more interesting
---
Diffs of the changes: (+54 -9)
ArrayCopy.java | 63 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 54 insertions(+), 9 deletions(-)
Index: llvm-java/test/Programs/SingleSource/UnitTests/ArrayCopy.java
diff -u llvm-java/test/Programs/SingleSource/UnitTests/ArrayCopy.java:1.2 llvm-java/test/Programs/SingleSource/UnitTests/ArrayCopy.java:1.3
--- llvm-java/test/Programs/SingleSource/UnitTests/ArrayCopy.java:1.2 Wed Feb 2 09:54:17 2005
+++ llvm-java/test/Programs/SingleSource/UnitTests/ArrayCopy.java Wed Feb 2 12:40:08 2005
@@ -2,20 +2,65 @@
public class ArrayCopy
{
+ public static Random rand = new Random(0);
+
public static int min(int a, int b) {
return a < b ? a : b;
}
+ public static void fillArray(Object dst, int dstLength, Object src, int srcLength) {
+ for (int i = 0; i < dstLength; i += srcLength)
+ System.arraycopy(src, 0, dst, i, min(dstLength - i, srcLength));
+ }
+
public static void main(String[] args) {
- int[] iarray1 = new int[10];
- for (int i = 0; i < iarray1.length; ++i)
- iarray1[i] = i;
-
- int[] iarray2 = new int[123];
- for (int i = 0; i < iarray2.length; i += iarray1.length)
- System.arraycopy(iarray1, 0, iarray2, i, min(iarray2.length - i, iarray1.length));
+ int[] isrc = new int[10];
+ byte[] bsrc = new byte[10];
+ float[] fsrc = new float[10];
+ double[] dsrc = new double[10];
+ boolean[] zsrc = new boolean[10];
+ long[] lsrc = new long[10];
+ Object[] osrc = new Object[10];
+
+ for (int i = 0; i < 10; ++i) {
+ isrc[i] = rand.nextInt();
+ bsrc[i] = (byte) rand.nextInt();
+ fsrc[i] = rand.nextFloat();
+ dsrc[i] = rand.nextDouble();
+ zsrc[i] = rand.nextBoolean();
+ lsrc[i] = rand.nextLong();
+ osrc[i] = new Integer(rand.nextInt());
+ }
+
+ int[] idst = new int[7];
+ byte[] bdst = new byte[19];
+ float[] fdst = new float[28];
+ double[] ddst = new double[23];
+ boolean[] zdst = new boolean[17];
+ long[] ldst = new long[6];
+ Object[] odst = new Object[22];
+
+ fillArray(idst, idst.length, isrc, isrc.length);
+ fillArray(bdst, bdst.length, bsrc, bsrc.length);
+ fillArray(fdst, fdst.length, fsrc, fsrc.length);
+ fillArray(ddst, ddst.length, dsrc, dsrc.length);
+ fillArray(zdst, zdst.length, zsrc, zsrc.length);
+ fillArray(ldst, ldst.length, lsrc, lsrc.length);
+ fillArray(odst, odst.length, osrc, osrc.length);
- for (int i = 0; i < iarray2.length; ++i)
- Test.println(iarray2[i]);
+ for (int i = 0; i < idst.length; ++i)
+ Test.println(idst[i]);
+ for (int i = 0; i < bdst.length; ++i)
+ Test.println(bdst[i]);
+ for (int i = 0; i < fdst.length; ++i)
+ Test.println(fdst[i]);
+ for (int i = 0; i < ddst.length; ++i)
+ Test.println(ddst[i]);
+ for (int i = 0; i < zdst.length; ++i)
+ Test.println(zdst[i]);
+ for (int i = 0; i < ldst.length; ++i)
+ Test.println(ldst[i]);
+ for (int i = 0; i < odst.length; ++i)
+ Test.println(((Integer)odst[i]).intValue());
}
}
More information about the llvm-commits
mailing list