Package org.djunits.util
Class Math2Test
java.lang.Object
org.djunits.util.Math2Test
Unit tests for
Math2. This suite aims for 100% line and branch coverage by exercising:
- Aggregations:
Math2.max(double...),Math2.min(double...),Math2.maxAbs(double...),Math2.minAbs(double...),Math2.sum(double...),Math2.sumAbs(double...),Math2.sumSqr(double...) Math2.median(double...)with odd/even counts andNaN-filtering behaviorMath2.pow(int, int)for various bases/exp and the negative-exponent error branch- Coverage of the private constructor
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidVerifiesMath2.maxAbs(double...)with negative/positive values and sentinels.(package private) voidVerifiesMath2.max(double...)for typical values, extremes, and sentinel behavior.(package private) voidVerifiesMath2.median(double...)across odd/even sizes, NaN filtering, single-value, and all-NaN inputs.(package private) voidVerifiesMath2.minAbs(double...)with negative/positive values (including -0.0) and sentinels.(package private) voidVerifiesMath2.min(double...)for typical values, extremes, and sentinel behavior.(package private) voidVerifiesMath2.pow(int, int)for diverse cases, including the negative-exponent error.(package private) voidCovers the private no-arg constructor ofMath2to attain full coverage of the class.(package private) voidVerifiesMath2.sumAbs(double...)produces the sum of absolute values and sentinel behavior.(package private) voidVerifiesMath2.sumSqr(double...)produces the sum of squares and sentinel behavior.(package private) voidVerifiesMath2.sum(double...)with typical inputs and sentinel behavior.
-
Constructor Details
-
Math2Test
public Math2Test()
-
-
Method Details
-
privateConstructorCoverage
Covers the private no-arg constructor ofMath2to attain full coverage of the class.- Throws:
Exception- on reflection errors (should not occur in normal environments)
-
maxValues
@Test void maxValues()VerifiesMath2.max(double...)for typical values, extremes, and sentinel behavior. -
minValues
@Test void minValues()VerifiesMath2.min(double...)for typical values, extremes, and sentinel behavior. -
maxAbsValues
@Test void maxAbsValues()VerifiesMath2.maxAbs(double...)with negative/positive values and sentinels. -
minAbsValues
@Test void minAbsValues()VerifiesMath2.minAbs(double...)with negative/positive values (including -0.0) and sentinels. -
sumValues
@Test void sumValues()VerifiesMath2.sum(double...)with typical inputs and sentinel behavior. -
sumAbsValues
@Test void sumAbsValues()VerifiesMath2.sumAbs(double...)produces the sum of absolute values and sentinel behavior. -
sumSqrValues
@Test void sumSqrValues()VerifiesMath2.sumSqr(double...)produces the sum of squares and sentinel behavior. -
medianVariants
@Test void medianVariants()VerifiesMath2.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()VerifiesMath2.pow(int, int)for diverse cases, including the negative-exponent error.
-