This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 7e0cc1e89 Fix NumberUtilsTest#testMaxDouble() and testMaxFloat()
(#1506)
7e0cc1e89 is described below
commit 7e0cc1e89037c2cd70d46897bf71530a8361d60a
Author: Michael Hausegger <[email protected]>
AuthorDate: Fri Nov 28 13:39:33 2025 +0100
Fix NumberUtilsTest#testMaxDouble() and testMaxFloat() (#1506)
* Corrected NumberUtilsTest#getMax... tests
* No need for extra message in this case
* No need to clutter things up
---------
Co-authored-by: TheRealHaui <[email protected]>
Co-authored-by: Gary Gregory <[email protected]>
---
.../apache/commons/lang3/math/NumberUtilsTest.java | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index beaeaf41d..8541ca986 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -1205,16 +1205,11 @@ void testMaxByte_nullArray() {
@Test
void testMaxDouble() {
- final double[] d = null;
- assertNullPointerException(() -> NumberUtils.max(d), "No exception was
thrown for null input.");
-
- assertIllegalArgumentException(NumberUtils::max, "No exception was
thrown for empty input.");
-
- assertEquals(5.1f, NumberUtils.max(5.1f), "max(double[]) failed for
array length 1");
- assertEquals(9.2f, NumberUtils.max(6.3f, 9.2f), "max(double[]) failed
for array length 2");
- assertEquals(10.4f, NumberUtils.max(-10.5f, -5.6f, 0, 5.7f, 10.4f),
"max(double[]) failed for float length 5");
- assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10), 0.0001);
- assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10), 0.0001);
+ assertEquals(5.1d, NumberUtils.max(5.1d), "max(double[]) failed for
array length 1");
+ assertEquals(9.2d, NumberUtils.max(6.3d, 9.2d), "max(double[]) failed
for array length 2");
+ assertEquals(10.4d, NumberUtils.max(-10.5d, -5.6d, 0, 5.7d, 10.4d),
"max(double[]) failed for double length 5");
+ assertEquals(10d, NumberUtils.max(-10d, -5d, 0d, 5d, 10d));
+ assertEquals(10d, NumberUtils.max(-5d, 0d, 10d, 5d, -10d));
}
@Test
@@ -1232,8 +1227,8 @@ void testMaxFloat() {
assertEquals(5.1f, NumberUtils.max(5.1f), "max(float[]) failed for
array length 1");
assertEquals(9.2f, NumberUtils.max(6.3f, 9.2f), "max(float[]) failed
for array length 2");
assertEquals(10.4f, NumberUtils.max(-10.5f, -5.6f, 0, 5.7f, 10.4f),
"max(float[]) failed for float length 5");
- assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10), 0.0001f);
- assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10), 0.0001f);
+ assertEquals(10f, NumberUtils.max(-10f, -5f, 0f, 5f, 10f), 0.0001f);
+ assertEquals(10f, NumberUtils.max(-5f, 0f, 10f, 5f, -10f), 0.0001f);
}
@Test