Class RegressionTesting


  • public class RegressionTesting
    extends Object
    Tools to help make regression testing easier, but also useful for other purposes.
    Author:
    pavlidis
    • 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​(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: