Class Math2Test

java.lang.Object
org.djunits.util.Math2Test

public class Math2Test extends Object
Unit tests for Math2. This suite aims for 100% line and branch coverage by exercising:

Conventions: Floating-point comparisons use tight absolute tolerances; wherever the API specifies Double.NaN as the sentinel for null/empty inputs, the tests assert that behavior explicitly. Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.

Author:
Alexander Verbraeck (specifications); Test implementation by Copilot.
  • Constructor Details

    • Math2Test

      public Math2Test()
  • Method Details

    • privateConstructorCoverage

      @Test void privateConstructorCoverage() throws Exception
      Covers the private no-arg constructor of Math2 to attain full coverage of the class.
      Throws:
      Exception - on reflection errors (should not occur in normal environments)
    • maxValues

      @Test void maxValues()
      Verifies Math2.max(double...) for typical values, extremes, and sentinel behavior.
    • minValues

      @Test void minValues()
      Verifies Math2.min(double...) for typical values, extremes, and sentinel behavior.
    • maxAbsValues

      @Test void maxAbsValues()
      Verifies Math2.maxAbs(double...) with negative/positive values and sentinels.
    • minAbsValues

      @Test void minAbsValues()
      Verifies Math2.minAbs(double...) with negative/positive values (including -0.0) and sentinels.
    • sumValues

      @Test void sumValues()
      Verifies Math2.sum(double...) with typical inputs and sentinel behavior.
    • sumAbsValues

      @Test void sumAbsValues()
      Verifies Math2.sumAbs(double...) produces the sum of absolute values and sentinel behavior.
    • sumSqrValues

      @Test void sumSqrValues()
      Verifies Math2.sumSqr(double...) produces the sum of squares and sentinel behavior.
    • medianVariants

      @Test void medianVariants()
      Verifies Math2.median(double...) across odd/even sizes, NaN filtering, single-value, and all-NaN inputs.
      • Odd count -> middle element
      • Even count -> average of two middle elements
      • NaNs are ignored; if all values are NaN -> Double.NaN
    • powVariants

      @Test void powVariants()
      Verifies Math2.pow(int, int) for diverse cases, including the negative-exponent error.