[llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Util.java

Alkis Evlogimenos alkis at cs.uiuc.edu
Thu Feb 3 13:29:47 PST 2005



Changes in directory llvm-java/test/Programs/SingleSource/UnitTests:

Util.java added (r1.1)
---
Log message:

Add Util.java - utility functions for testing

---
Diffs of the changes:  (+184 -0)

 Util.java |  184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 184 insertions(+)


Index: llvm-java/test/Programs/SingleSource/UnitTests/Util.java
diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/Util.java:1.1
*** /dev/null	Thu Feb  3 15:29:46 2005
--- llvm-java/test/Programs/SingleSource/UnitTests/Util.java	Thu Feb  3 15:29:36 2005
***************
*** 0 ****
--- 1,184 ----
+ import java.util.*;
+ 
+ public class Util
+ {
+     private static Random rand = new Random(0);
+ 
+     public static void randomFill(boolean[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(boolean[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = rand.nextBoolean();
+     }
+ 
+     public static void randomFill(byte[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(byte[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = (byte) rand.nextInt();
+     }
+ 
+     public static void randomFill(char[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(char[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = (char) rand.nextInt();
+     }
+ 
+     public static void randomFill(double[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(double[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = rand.nextDouble();
+     }
+ 
+     public static void randomFill(float[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(float[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = rand.nextFloat();
+     }
+ 
+     public static void randomFill(int[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(int[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = rand.nextInt();
+     }
+ 
+     public static void randomFill(long[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(long[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = rand.nextLong();
+     }
+ 
+     public static void randomFill(short[] a) {
+         randomFill(a, 0, a.length);
+     }
+ 
+     public static void randomFill(short[] a, int from, int to) {
+         for (; from < to; ++from)
+             a[from] = (short) rand.nextInt();
+     }
+ 
+     public static void printlnElements(boolean[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(boolean[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void printlnElements(byte[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(byte[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void printlnElements(char[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(char[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void printlnElements(double[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(double[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void printlnElements(float[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(float[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void printlnElements(int[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(int[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void printlnElements(long[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(long[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void printlnElements(short[] a) {
+         printlnElements(a, 0, a.length);
+     }
+ 
+     public static void printlnElements(short[] a, int from, int to) {
+         for (; from < to; ++from)
+             Test.println(a[from]);
+     }
+ 
+     public static void main(String[] args) {
+         boolean[] az = new boolean[rand.nextInt(100)];
+         randomFill(az);
+         printlnElements(az);
+ 
+         byte[] ab = new byte[rand.nextInt(100)];
+         randomFill(ab);
+         printlnElements(ab);
+ 
+         char[] ac = new char[rand.nextInt(100)];
+         randomFill(ac);
+         printlnElements(ac);
+ 
+         double[] ad = new double[rand.nextInt(100)];
+         randomFill(ad);
+         printlnElements(ad);
+ 
+         float[] af = new float[rand.nextInt(100)];
+         randomFill(af);
+         printlnElements(af);
+ 
+         int[] ai = new int[rand.nextInt(100)];
+         randomFill(ai);
+         printlnElements(ai);
+ 
+         long[] al = new long[rand.nextInt(100)];
+         randomFill(al);
+         printlnElements(al);
+ 
+         short[] as = new short[rand.nextInt(100)];
+         randomFill(as);
+         printlnElements(as);
+     }
+ }






More information about the llvm-commits mailing list