Package ubic.basecode.util
Class RegressionTesting
- java.lang.Object
-
- ubic.basecode.util.RegressionTesting
-
public class RegressionTesting extends Object
Tools to help make regression testing easier, but also useful for other purposes.- Author:
- pavlidis
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancloseEnough(double[] expected, double[] actual, double tolerance)static booleancloseEnough(cern.colt.list.DoubleArrayList expected, cern.colt.list.DoubleArrayList actual, double tolerance)Test whether two DoubleArrayLists are 'close enough' to call equal.static booleancloseEnough(cern.colt.matrix.DoubleMatrix1D expected, cern.colt.matrix.DoubleMatrix1D actual, double tolerance)static booleancloseEnough(cern.colt.matrix.DoubleMatrix2D a, cern.colt.matrix.DoubleMatrix2D b, double tolerance)static booleancloseEnough(Object[] a, Object[] b)Test whether two object arrays are the same.static booleancloseEnough(DoubleMatrix<?,?> expected, DoubleMatrix<?,?> actual, double tolerance)Test whether two AbstractNamedDoubleMatrix are 'close enough' to call equal.static booleancontainsSame(double[] a, double[] b)Test whether two double arrays contain the same items in any order (tolerance is ZERO)static booleancontainsSame(Object[] a, Object[] b)Test whether two object arrays contain the same items in any order.static booleancontainsSame(Collection<? extends Object> a, Collection<? extends Object> b)Test whether two collections contain the same items.static StringreadTestResult(File file)static StringreadTestResult(InputStream istream)static StringreadTestResult(String resourceName)static StringreadTestResultFromFile(String fileName)static booleansameArray(int[] a, int[] b)Test whether two double arrays contain the same items in the same orderstatic voidwriteTestResult(String result, String fileName)
-
-
-
Method Detail
-
closeEnough
public static boolean closeEnough(double[] expected, double[] actual, double tolerance)- Parameters:
expected-actual-tolerance- permitted delta between the values
-
closeEnough
public static boolean closeEnough(cern.colt.list.DoubleArrayList expected, cern.colt.list.DoubleArrayList actual, double tolerance)Test whether two DoubleArrayLists are 'close enough' to call equal.- Parameters:
expected-actual-tolerance-- Returns:
-
closeEnough
public static boolean closeEnough(DoubleMatrix<?,?> expected, DoubleMatrix<?,?> actual, double tolerance)
Test whether two AbstractNamedDoubleMatrix are 'close enough' to call equal.- Parameters:
expected-actual-tolerance-- Returns:
- try if all the values in both matrices are within 'tolerance' of each other.
-
closeEnough
public static boolean closeEnough(cern.colt.matrix.DoubleMatrix1D expected, cern.colt.matrix.DoubleMatrix1D actual, double tolerance)- Parameters:
expected-actual-tolerance-- Returns:
-
closeEnough
public static boolean closeEnough(cern.colt.matrix.DoubleMatrix2D a, cern.colt.matrix.DoubleMatrix2D b, double tolerance)
-
closeEnough
public static boolean closeEnough(Object[] a, Object[] b)
Test whether two object arrays are the same.- Parameters:
a-b-- Returns:
-
containsSame
public static boolean containsSame(Collection<? extends Object> a, Collection<? extends Object> b)
Test whether two collections contain the same items.- Parameters:
a-b-- Returns:
-
containsSame
public static boolean containsSame(double[] a, double[] b)Test whether two double arrays contain the same items in any order (tolerance is ZERO)- Parameters:
a-b-- Returns:
-
containsSame
public static boolean containsSame(Object[] a, Object[] b)
Test whether two object arrays contain the same items in any order. The arrays are treated as Sets - repeats are not considered.- Parameters:
a-b-- Returns:
-
readTestResult
public static String readTestResult(File file) throws IOException
- Parameters:
file-- Returns:
- Throws:
IOException
-
readTestResult
public static String readTestResult(InputStream istream) throws IOException
- Parameters:
istream-- Returns:
- Throws:
IOException
-
readTestResult
public static String readTestResult(String resourceName) throws IOException
- Parameters:
resourceName-- Returns:
- the contents of the resource as a String
- Throws:
IOException
-
readTestResultFromFile
public static String readTestResultFromFile(String fileName) throws IOException
- Parameters:
fileName- - the full path of the file to be read.- Returns:
- Throws:
IOException
-
sameArray
public static boolean sameArray(int[] a, int[] b)Test whether two double arrays contain the same items in the same order- Parameters:
a-b-- Returns:
-
writeTestResult
public static void writeTestResult(String result, String fileName) throws IOException
- Throws:
IOException
-
-