//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** @author John Miller * @version 1.2 * @date Tue Mar 29 16:54:57 EDT 2016 * @see LICENSE (MIT style license file). */ package testing.stat import org.junit.Test import scala.math._ import scalation.stat.StatVector import scalation.random._ import testing.Tester //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** The `StatVector_T` driver class conducts unit testing on the `StatVector` class * by invoking the StatVector_T testing object. Run 'test-only' to test `StatVector` * or 'test' to run all unit tests. *------------------------------------------------------------------------------ * > test-only testing.stat.StatVector_T * > test */ class StatVector_T { @Test def testAll () { StatVector_T } } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** The `StatVector_T` testing object conducts unit testing on the `StatVector` class * using the `Tester` trait. It compares correctness/performance of a method/operator * 'call' to an 'oracle' and optionally a 'contender'. *------------------------------------------------------------------------------ * All methods except 'this', 'apply', 'update', 'foreach' and 'hashCode' should be tested. * May skip '=op' if 'op' is tested, e.g., skip '+=' if '+' is tested. * Also the 'equals' and 'toString' are tested implicitly. * Depending on the 'CORRECT' flag, it will either test correctness or performance. * Note, if the code for the 'contender' or even the 'oracle' is significantly faster, * the method/operator may need be to re-coded. *------------------------------------------------------------------------------ * To run directly, uncomment "// with App" and run 'test:runMain'. * > test:runMain testing.stat.StatVector_T */ object StatVector_T extends Tester // with App { // Reassign parameters from `Tester` trait as needed DEBUG = false // debug flag CORRECT = true // test correctness/performance FOCUS = "" // method/operator to focus on, "" => all KLASS = "StatVector" // the class under test ITER = 100 // number of test iterations // Size parameter(s) used for variables in 'test' (customize per class) private val dim = 10 // vector size // Random variate generators (customize per class) private val rv = RandomVecD (count = dim, density = 1.0) // random vector generator private val rn = Uniform (0.0, 100.0) // random double generator private val rj = Randi0 (0, dim) // random integer/index generator // Variables used in 'test' (customize per class) private val x = new VectorD (dim) // first vector private val y = new VectorD (dim) // second vector private var s = 0.0 // scalar value private var j = 0 // first integer/index value private var k = 0 // second integer/index value //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** Randomize all variables used in `Tester`s 'test' method. */ def randomize () { x set rv.gen () // randomly reset variables y set rv.gen () s = rn.gen j = rj.igen k = rj.igen } // randomize testClass () println ("\nTest methods/unary operators") test (mean, x.mean, ) test (median, x.median, ) test (self, x.self, ) test (precision, x.precision, ) test (amedian, x.amedian, ) test (cov, x.cov, ) test (pcov, x.pcov, ) test (acov, x.acov, ) test (corr, x.corr, ) test (pcorr, x.pcorr, ) test (scorr, x.scorr, ) test (acorr, x.acorr, ) test (stddev, x.stddev, ) test (pstddev, x.pstddev, ) test (ms, x.ms, ) test (rms, x.rms, ) test (skew, x.skew, ) test (kurtosis, x.kurtosis, ) test (t_sigma, x.t_sigma, ) test (interval, x.interval, ) test (precise, x.precise, ) test (standardize, x.standardize, ) test (equals, x.equals, ) test (hashCode, x.hashCode, ) test (wait, x.wait, ) test (wait, x.wait, ) test (wait, x.wait, ) test (toString, x.toString, ) test (getClass, x.getClass, ) test (notify, x.notify, ) test (notifyAll, x.notifyAll, ) } // StatVector_T object