Class ExperimentTest


  • public class ExperimentTest
    extends Object
    Utility class that can be used as a base class for JUnit tests which check for many results of an Experiment at once. Deriving a new test class from ExperimentTest and calling checkResults(Map, Map) many results of an experiment can be validated with a single method call.
    Author:
    Torsten Hildebrandt, 2012-08-08
    • Field Detail

      • errorCollector

        public org.junit.rules.ErrorCollector errorCollector
      • maxUlps

        protected int maxUlps
        precision in terms of ULPs (Units in the last place), so FP comparisons work for large and small numbers;
        See Also:
    • Constructor Detail

      • ExperimentTest

        public ExperimentTest()
    • Method Detail

      • checkKeySets

        protected void checkKeySets​(Map<String,​Object> resActual,
                                    Map<String,​Object> resExpected)
        Checks whether key sets of actual and expected results are the same.
        Parameters:
        resActual - The map of results actually obtained.
        resExpected - The map of expected results.
      • checkResults

        protected void checkResults​(Map<String,​Object> resActual,
                                    Map<String,​Object> resExpected)
        Checks if all keys in resExpected are also present in resActual and have the same values. Additional keys in resActual as well as the key "runTime" are ignored.
        Parameters:
        resActual - The map of results actually obtained.
        resExpected - The map of expected results.
      • checkFloat

        protected void checkFloat​(String name,
                                  float act,
                                  float exp)
      • checkDouble

        protected void checkDouble​(String name,
                                   double act,
                                   double exp)